From: Todd Simpson <todo@erols.com>
Subject: Re: "Invalid argument" error from close() system call
Date: 2000/10/23 [thread overview]
Message-ID: <39F4F219.4D52C077@erols.com> (raw)
In-Reply-To: 8t0bfp$erk$1@bob.news.rcn.net
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
prev parent reply other threads:[~2000-10-23 4:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-23 3:31 "Invalid argument" error from close() system call Todd Simpson
2000-10-23 4:00 ` Todd Simpson [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox