Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!julius.cs.uiuc.edu!rpi!clarkson!grape.ecs.clarkson.edu!towfiq From: towfiq@FTP.COM (Mark Towfiq) Newsgroups: comp.protocols.tcp-ip Subject: Re: select() call weirdness Message-ID: Date: 23 Jan 91 18:52:47 GMT References: <9101171257.AA13517@fiamass.ie> Sender: @grape.ecs.clarkson.edu Reply-To: towfiq@FTP.COM Organization: FTP Software, Inc., Wakefield, MA Lines: 40 In-Reply-To: fiamass@fiamass.ie's message of 17 Jan 91 12:57:45 GMT In article <9101171257.AA13517@fiamass.ie> fiamass@fiamass.ie (fiamass) writes: We are having a problem with the select() system call on a Sun Sparc 4/65 running SunOS 4.1. We have a non blocking socket which we use to issue a connect(). This call returns EINPROGRESS as per the documentation. The documentation states that under these circumstatances a select() call for write on that socket can be done to determine when the socket is fully connected. Now here is our problem, we make a select() call which always seems to return telling me that the socket is now connected. So on I go and issue a write() which causes the program to bomb out! It is as if the write call does not return. Has anyone any ideas? First, the question here is what is the purpose of the select() call. In my experience, select() is used in two situations: 1) you have more than one socket/file descriptor which you want to perform operations on, so you use select to find out which one is ready, perform the operations, and come back to the select; 2) you have an operation which you want to complete in a certain amount of time (for example this is used in the name resolver code to send out a few UDP packets to one nameserver, then another, and so on. From your example it does not seem to me that you need select for either of these reasons, although perhaps that is just a test program. I don't know for sure why on a Sun your code does not work, but I would suggest some modifications to your code: 1) check the return value of the select call, and use the information as provided by the manual to decipher what the value might me. If this doesn't work, try 2) using an actual timeout value, as another poster suggested. If this still doesn't work, then try 3) doing your connnect before making the socket non-blocking. If none of this works, someone is broken somewhere. Hope this helps, Mark -- Mark Towfiq, FTP Software, Inc. towfiq@FTP.COM Work No.: +1 617 246 0900 Home No.: +1 617 488 2818 "The Earth is but One Country, and Mankind its Citizens" -- Baha'u'llah