connect(2) for UDP

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
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
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.