Re: connect(2) for UDP
Peter Deacon <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <alpine.WNT.2.00.0812171117520.1988@SMURF> |
On Wed, 17 Dec 2008, James K. Lowden wrote: > Possible conditions: > 1. gethostbyname() fails. Don't try 1434. > 2. connect/write/read to 1434 succeeds. Hurrah! > 3. connect/write/read to 1434 yields ECONNREFUSED. Named instances > unsupported. > 4. connect/write/read to 1434 times out. Host down *or* host responding > from different interface. > Well, first try connected. It's quicker if it works, and it establishes > (#3) whether or not anyone's listening to 1434. > For autodetection, for #4 I would assume the host is down, because > retrying is too slow (especially if it's actually a 5.0 server). But if, > say, freetds.conf had "port = AUTO", then I'd try unconnected UDP. I'm > also tempted to fork(2) and try both at the same time. (The child could > write the results to the parent via a pipe.) Recommend using bind() rather than connect() with UDP. With bind you still get ICMP indiciations for fast failure when send()ing. Have Fun! Peter