Re: Asynchronous connection to socket always appears to succeed?

Chris Angelico <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <CAPTjJmpqMPwp-Vcs3csT7rxCJewLev=AOhck7p_6mkofM+Qv0Q@mail.gmail.com>
On Thu, Jul 30, 2015 at 1:57 AM, Pontus Rodling <[email protected]> wrote:
> Hi Chris,
>
> I can't say I've seen it done that way before but, here are two examples
> of what I usually do using connect() or async_connect():

Hmm. I can get your async_connect() demo to work, but it destroys
errno(), so there's no way for me to find out _why_ the connection
failed (refused? timeout? no route to host?). But given that I'm not
even getting notified _at all_, that might be the only way about it.

Looking at the implementation thereof, it seems to use the same
callback for all cases, but then check if the socket is open and
connected to determine the error status. I can do the same check in my
code, and it does appear to show me what's going on, but even checking
sock->errno() prior to the query_address() call doesn't tell me what
the actual error was. Is there no way to get that info from an
asynchronous connection? Compare:

object f=Stdio.File(); f->connect("127.0.0.1",23); f->errno();

You'll get back an errno that tells you exactly what's going on.

ChrisA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.