From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,9ee22207af5a0e7d X-Google-Attributes: gidfa528,public From: Todd Simpson Subject: Re: "Invalid argument" error from close() system call Date: 2000/10/23 Message-ID: <39F4F219.4D52C077@erols.com>#1/1 X-Deja-AN: 685069174 Content-Transfer-Encoding: 7bit References: <8t0bfp$erk$1@bob.news.rcn.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@rcn.com X-Trace: bc/sHAjVK2D7wSBKcUxT7A5RdrQv82ILTKf2Cqfd7XY= Organization: None Mime-Version: 1.0 NNTP-Posting-Date: 24 Oct 2000 02:21:52 GMT Newsgroups: comp.unix.tru64 Todd Simpson wrote: > > I'm using a Compaq AlphaStation DS10 with Tru64 Unix V5.0A. I compile > some API routines provided by a company to communicate with a so-called > protocol server that it manufactures. This server is a machine that's on > the net and the software on the DS10 uses a TCP protocol socket to > communicate with it. The compilation gives no errors and when I run the > software, it works just as I expect - until I use the API routine to close > the > connection to the server. The routine calls the Unix system close() > function > with the socket file descriptor as its argument. The function returns an > error > condition of "Invalid argument". This happens right after a write() to the > socket > completes successfully. The man page does not mention "Invalid argument" > (EINVAL) as an error condition from close(). Any clues as to what is going > on or what to do about it? > > Thanks in advance, > Todd > > Todd Simpson > todo@erols.com I took another look at the source code today to see how the socket was opened. One thing I thought looked strange was that the setsockopt() function was used to set the socket for "linger on close" (SO_LINGER) with a timeout of zero. What would be the point of setting the socket to linger so that a write operation can finish if you don't give it time to finish? I ran simple test programs to see how this affected the behavior of the socket. It looked like data sent to the socket by one program was not read by the other program. When I used a timeout greater than zero, the data did appear to get read. So I changed the source code for the API routine to use a linger timeout of 1. The "Invalid argument" error went away. This makes it look like a problem with the linger option. I don't know what the solution will be in my case, but I'm more confident that there will be a solution. Thanks to all who took the time to look into this.... Todd Todd Simpson todo@erols.com