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.9 required=5.0 tests=BAYES_00 autolearn=ham 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 11:22:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!easynet-quince!easynet.net!teaser.fr!enst.fr!beeblebrox!nobody From: Samuel Tardieu Newsgroups: comp.lang.ada Subject: Re: [OT] Two sockets questions Date: Wed, 07 May 2003 20:22:52 +0200 Organization: Avian Carrier & Friends Message-ID: <8765omaa6b.fsf@inf.enst.fr> References: NNTP-Posting-Host: beeblebrox.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: avanie.enst.fr 1052331775 85123 137.194.162.67 (7 May 2003 18:22:55 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 7 May 2003 18:22:55 +0000 (UTC) Mail-Copies-To: sam@rfc1149.net User-Agent: Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Military Intelligence, i386--freebsd) Cancel-Lock: sha1:FP4AuuKZraBzezQ6UAap2gB9YnU= Xref: archiver1.google.com comp.lang.ada:37037 Date: 2003-05-07T20:22:52+02:00 List-Id: >>>>> "Jano" == Jano writes: Jano> Is there a way of performing a connect without blocking on it? I Jano> suspect not... and if not in Ada, by other means? 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). 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. Sam -- Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam