[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I know a connect was rejected, and why?
>
> Dumb question but the answer isn't obvious from looking at manpages or
> code...
>
> If I do a connect, and the connect is rejected, how can I tell? It
> seems the connect call succeeds, but when you then try to read data
> from the socket it fails.
>
If connect() returns -1, then you've got an error of some sort
getsockopt(...DSO_DISDATA..) to get at the disconnect data. It returns
a status as well as the actual (optional) data.
> There's a specific "rejected" link state, but I don't see how that's
> visible from the application. And besides, I need to have the reject
> code.
>
You can use getsockopt(...DSO_LINKINFO...) to find out the logical link
state of the socket, but the only other method at the moment is to
parse /proc/net/decnet (see my previus post on the list) which is not
whta I'd recommend...
> One scenario: the clean way to do sethost to non-cterm hosts is to try
> to connect to cterm, then if that fails with reason == no such object,
> retry with the other object number.
>
> paul
You should be able to grab the reason with the DSO_DISDATA call. The only
thing to remember is to close() the failed socket and open a new one to
try and connect to a different object. The disconnect data responses
have not been tested very well though, you may well uncover some bugs there,
Steve.
-----------------------------------------------------------------------------
To unsubscribe from this list, send a mail to majordomo@dreamtime.org
containing the line "unsubscribe linux-decnet"
-----------------------------------------------------------------------------