From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,URI_HEX autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c22949b5ebf3505f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-07 13:02:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!212.97.175.23!not-for-mail From: Jano Newsgroups: comp.lang.ada Subject: Re: [OT] Two sockets questions Date: Wed, 7 May 2003 22:02:15 +0200 Message-ID: References: <8765omaa6b.fsf@inf.enst.fr> NNTP-Posting-Host: 212.97.175.23 X-Trace: fu-berlin.de 1052337744 18765418 212.97.175.23 (16 [49872]) X-Newsreader: MicroPlanet Gravity v2.50 Xref: archiver1.google.com comp.lang.ada:37045 Date: 2003-05-07T22:02:15+02:00 List-Id: Samuel Tardieu dice... > Sure! I'll describe the process in C, I do not know whether > GNAT.Sockets allows you to do all those steps: > > 1) Create your socket > 2) Make it non-blocking > 3) connect() will return immediately with either 0 (success), -1 > with errno set to EINPROGRESS or -1 with another error (real > error). > 4) If the result was -1/EINPROGRESS, do a select() on the socket for > writing. When it tells you that you can write, write() 0 bytes. If > there is no error (write() returns 0), then you are > connected. Otherwise, you will get an error (typically > -1/ENOTCONN). Great! I must try these things. > Jano> Second: I have a connected socket which I poll periodically for > Jano> data. When there is no more data available and the other > Jano> endpoint has closed the socket, I continue receiving 0 byte > Jano> available but not notification of closed socket. It's only when > Jano> I try to read/write that a exception is raised about the > Jano> connection reset or something. Is there a mean to be aware that > Jano> connection has been closed (after the available data is > Jano> exhausted, I presume)? > > If you select() the socket for reading and select() tells you that > there is data available and if read() returns 0 bytes, then this means > that the other side has shutdown its sending part. Mmm... The Gnat.Sockets package has a select binding... I wonder if it behaves that way. I will obviously test it ;-) A idea that comes to me: If I do a read for 0 bytes, will occur the same? I mean, if connection is alive, nothing happens, and if it's dead, error... Many thanks! -- ------------------------- Jano 402450.at.cepsz.unizar.es -------------------------