Networking Forums

Networking Forums > Computer Networking > Linux Networking > Unconnect a UDP Socket

Reply
Thread Tools Display Modes

Unconnect a UDP Socket

 
 
Frank A. Uepping
Guest
Posts: n/a

 
      11-23-2003, 01:08 PM
Hi,
a UDP socket may be connect()ed. That is, the UDP socket only accepts/sends
datagrams from/to the connected destination.
Is it possible to un-connect a UDP socket (that is, revert the socket back
to the unconnected state)?

/FAU

 
Reply With Quote
 
 
 
 
Michael Fuhr
Guest
Posts: n/a

 
      11-23-2003, 06:58 PM
"Frank A. Uepping" <(E-Mail Removed)> writes:

> a UDP socket may be connect()ed. That is, the UDP socket only accepts/sends
> datagrams from/to the connected destination.
> Is it possible to un-connect a UDP socket (that is, revert the socket back
> to the unconnected state)?


I haven't tried this on Linux, but here's an excerpt from the socket
programming bible, _UNIX Network Programming_, Volume 1, by W.
Richard Stevens, p. 226:

To unconnect a UDP socket we call connect but set the family member
of the socket address structure (sin_family for IPv4 or sin6_family
for IPv6) to AF_UNSPEC. This might return an error of EAFNOSUPPORT
(p. 736 of TCPv2) but that is OK. It is the process of calling
connect on an already connected UDP socket that causes the socket
to become unconnected (pp. 787-788 of TCPv2).

"TCPv2" refers to _TCP/IP Illustrated_, Volume 2, which is a detailed
description of the BSD implementation.

Try it and let us know if it works the way you expect.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
 
Reply With Quote
 
Frank A. Uepping
Guest
Posts: n/a

 
      11-24-2003, 08:52 AM
Michael Fuhr wrote:

> "Frank A. Uepping" <(E-Mail Removed)> writes:
>
>> a UDP socket may be connect()ed. That is, the UDP socket only
>> accepts/sends datagrams from/to the connected destination.
>> Is it possible to un-connect a UDP socket (that is, revert the socket
>> back to the unconnected state)?

>
> I haven't tried this on Linux, but here's an excerpt from the socket
> programming bible, _UNIX Network Programming_, Volume 1, by W.
> Richard Stevens, p. 226:
>
> To unconnect a UDP socket we call connect but set the family member
> of the socket address structure (sin_family for IPv4 or sin6_family
> for IPv6) to AF_UNSPEC. This might return an error of EAFNOSUPPORT
> (p. 736 of TCPv2) but that is OK. It is the process of calling
> connect on an already connected UDP socket that causes the socket
> to become unconnected (pp. 787-788 of TCPv2).
>
> "TCPv2" refers to _TCP/IP Illustrated_, Volume 2, which is a detailed
> description of the BSD implementation.
>
> Try it and let us know if it works the way you expect.
>

struct sockaddr sa;
sa.sa_family = AF_UNSPEC;
connect(fd, &sa, sizeof sa); // == 0

Yes it works (the result of connect() is 0 not EAFNOSUPPORT).
But you must set the size to sizeof(struct sockaddr) not sockaddr_in or
anything else!

/FAU

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test socket on Master Socket not working Kevin Cowans Broadband 14 11-15-2006 09:17 PM
10038 Socket Operation on non-socket =?Utf-8?B?UkNyYWlnTGF3MUBhb2wuY29t?= Windows Networking 3 12-23-2004 03:01 AM
10038 socket operation on non-socket Bill H. Windows Networking 1 09-27-2004 03:56 AM
10038 Socket Operation on non-socket error Tim G Windows Networking 1 09-26-2004 03:04 PM
WLAN Monitor 10038 Socket operation on non-socket Bill Windows Networking 1 03-01-2004 10:34 PM



1 2 3 4 5 6 7 8 9 10 11