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: Bill Auerbach
Subject: RE: [lwip-users] OT: Binding UDP in WinXP
Date: Thu, 16 Jul 2009 14:02:52 -0400

That's interesting Jeff.  If WinXP can do this, I was unable to find out how
or to make it work by experimentation.  I wonder if Windows is trying to
limit the number of sockets in use?  If it worked, you could have a socket
per device that received only data sent from the device.  But that's a
socket and (in my case) a thread per device. I implemented recvfrom and now
it's done one thread with a quick IP address look-up and dispatch to the
object that would have had its own thread.

Thanks for replying,
Bill

>-----Original Message-----
>From: address@hidden
>[mailto:address@hidden On
>Behalf Of Jeff Barber
>Sent: Thursday, July 16, 2009 1:13 PM
>To: Mailing list for lwIP users
>Subject: Re: [lwip-users] OT: Binding UDP in WinXP
>
>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
>>
>
>
>_______________________________________________
>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]