Re: connect(2) for UDP
"Jackson, Craig (Gale)" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
I don't think this is true. I don't think connect(2) sends any packets for UDP. It just sets up bookkeeping for subsequent write() and read() calls. However, I think after a write(), a subsequent read() may be able to learn that it had gotten an ICMP Port Unreachable, which is the diagnostic when no one is listening on a UDP port. Craig -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of James K. Lowden Sent: Monday, December 15, 2008 1:39 AM To: TDS Development Group Subject: [freetds] connect(2) for UDP Hello Frediano! /* * Request the instance's port from the server. * There is no easy way to detect if port is closed so we always try to * get a reply from server 16 times. */ for (num_try = 0; num_try < 16; ++num_try) { But there is an easy way: use connect(2) and write(2) instead of sendto! connect(2) sets errno to ECONNREFUSED if no one is listening to the port, even for UDP. This would let us know immediately if port 1434 is reachable, and could reduce our retry loop to, say, three tries. I was quite busy this weekend, as you see in the ChangeLog. Removing tds->last_packet might cause some surprises, but seems to work. Regards, --jkl _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds