[Nagiosplug-devel] Flight 1.4.8, ready for boarding

Andreas Ericsson ae at op5.se
Tue Apr 3 11:57:53 CEST 2007

Thomas Guyot-Sionnest wrote:
> On 02/04/07 06:08 PM, sean finney wrote:
> There might be another way. According to the article below to disconnect
> a UDP socket you have to call connect with the family member of the
> socket address structure to AF_UNSPEC. If you don't beat me it time I'll
> try to code that and see what happens.

Linux doesn't support disconnecting by specifying AF_UNSPEC, as per the
connect(2) man-page.

       Unconnecting  a socket by calling connect() with a AF_UNSPEC address is
       not yet implemented.

> If someone can tell me what should I use for the 3rd arg of connect()
> that'll help, otherwise it won't take me long to figure it out :)

sizeof(struct sockaddr), as Sean has already pointed out.

You shouldn't have to use connect(2) at all, as UDP is not a stateful protocol.
Instead you should be able to use sendto(2) and recvfrom(2).

I'll have a look at it and see if I can find something.

For techincal completeness; connect(2) only associates a socket with the
specified address inside the kernel. If it's used with UDP sockets, no further
action is taken. If used with a TCP socket, the 3-way TCP handshake is initiated
and the caller is by default made to wait the predefined socket timeout value if
no connection can be established. The socket timeout can be set by using

Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

More information about the Devel mailing list