lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] OT: Binding UDP in WinXP


From: Jeff Barber
Subject: Re: [lwip-users] OT: Binding UDP in WinXP
Date: Thu, 16 Jul 2009 13:13:23 -0400

That's not true for the BSD socket API.  Connect(2) has always worked
with UDP sockets as well.  See, for example
"http://www.manpages.info/freebsd/connect.2.html"; which includes this
text:
     If [the socket descriptor] is of type SOCK_DGRAM, this call
     specifies the peer with which the socket is to be associated; this
     address is that to which datagrams are to be sent, and the only address
     from which datagrams are to be received.

The openbsd, sunos, and linux manual pages all have similar text.
Using connect allows one to use recv(2) instead of recvfrom(2) (since
the address of the remote peer is already known).

Jeff

On Wed, Jul 15, 2009 at 6:32 PM, David Empson<address@hidden> wrote:
> You can't. :-)
>
> Looking at the BSD socket API in general, the point of bind() is to specify
> a local "name" (family, address and port) for the socket. It doesn't say
> anything about the remote IP address or port.
>
> With TCP, you must bind() the listening socket (since it requires a well
> known port) but typically don't bind the connecting socket unless it also
> needs to use a fixed port.
>
> With UDP, you typically bind() any socket which needs to receive data on a
> well known port, but don't bother for one that is just sending data (or one
> which will remain open for receive, and other devices find out which port
> you are using due to receiving data from you or through other means).
>
> The address in the bind() call must be one of your own IP addresses,
> typically that of a specific network interface. You can use IP_ADDRANY to
> leave your socket able to communicate via any network interface.
>
> An unbound socket will use IP_ADDRANY and a randomly assigned port number.
>
> If you are receiving UDP data from two devices on the same socket (i.e. both
> are sending data to the same port), you call recvfrom() and use the address
> passed back via the "from" parameter to distinguish them.
>
> ----- Original Message -----
>
> From: Bill Auerbach
> To: 'Mailing list for lwIP users'
> Sent: Thursday, July 16, 2009 6:53 AM
> Subject: [lwip-users] OT: Binding UDP in WinXP
>
> After half a day at this problem that I can’t solve, I figure someone here
> might say the answer is, “You can’t” and I’ll know I have a big problem. J
>
> I can send UDP data from WinXP to lwIP using SentTo no problem.  I can
> receive from lwIP if I use the port and IP_ADDRANY.  I realized with 2 of my
> devices connected I have a problem so I tried to bind the UDP socket in
> WinXP to the IP address and port of the lwIP device (I know it from a prior
> UDP “here I am” broadcast).  WinXP refuses to bind (or connect) to a
> specific IP address.  I know I’m missing something and spent half the day
> not finding it.  How do you bind a WinXP SOCK_DGRAM socket to a remote IP
> address and port?
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]