Re: connect(2) for UDP

"Frediano Ziglio" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
2008/12/18 Peter Deacon <[email protected]>:
> On Wed, 17 Dec 2008, Peter Deacon wrote:
>
>> Recommend using bind() rather than connect() with UDP.  With bind you
>> still get ICMP indiciations for fast failure when send()ing.
>
> More specifically..
>
> bind()
> sendto()
> select() for response
>
> The select will wake on either the expiration of the timer, data to be
> read or a failure hint if it turns out nothing was listening on the port
> from the previous sendto()
>

Oppss... I was wrong...
I did some tests with Python (only 5 lines to send and receive a
datagram, what a nice language :) ):
- server reply from a fix interface (netstat say sql browser bind at any:1434)
- using bind have a security problem (SELinux or a firewall can refuse
the bind) but when you send a packet kernel set the output port and do
a sort of bind (you can understand it calling getsockname)
- using connect filter packets from server so in the case of more
interfaces in server you lose the reply
- in case server is not listening to port 1434 it reply ICMP and
recvfrom return suddently with ECONNREFUSED
So you have timeout if
1- server is not alive (obviously!)
2- you use connect
3- you ask for a specific instance
so using current code detects port close suddently but
tds7_get_instance_port require a lot of time if there isn't the given
interface. The method is compatible with MS one (asking for a proper
instance) but I think it would be better to require all instances so
server always reply and in case of missing instance
tds7_get_instance_port return suddently.

Regards
  Frediano Ziglio
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.