buglwIP - A Lightweight TCP/IP stack - Bugs: bug #65581, UDP Socket Bind Should Bind To...


You are not allowed to post comments on this tracker with your current authentication level.

bug #65581: UDP Socket Bind Should Bind To Device

Submitter:  Matt Grochowalski <grochoge>
Submitted:  Wed 10 Apr 2024 07:02:45 PM UTC
Category:  UDP Severity:  3 - Normal
Item Group:  Change Request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  git head

Thu 11 Apr 2024 01:44:13 PM UTC, comment #3: 

I happen to have an application that also sends multicast traffic. It does bind() but also sets the socket option IP_MULTICAST_IF before calling sendto(). That requires having LWIP_MULTICAST_TX_OPTIONS set.
That might be a more "standard" workaround than using LWIP_HOOK_IP4_ROUTE_SRC.

Matthias Dietrich <matthiasdietrich>
Wed 10 Apr 2024 08:40:20 PM UTC, comment #2: 

Linux behaves the same way.

Example setup:
sudo ip link add veth1 type veth peer name veth2
sudo ip addr add dev veth1
sudo ip link set veth1 up
sudo ip link set veth2 up

Start Wireshark capture on interface veth2

Run in Python:
import socket
sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
sock.bind( ( '', 1234 ) )
sock.sendto( b'1234', ( '', 1234 ) )

Send succeeds and packet from to is shown in Wireshark

I see now there is a fairly trivial way to get this working by defining a LWIP_HOOK_IP4_ROUTE_SRC hook that returns the adapter with IP matching src.
But it would be nice to have an option to make this work like other socket implementations.

Matt Grochowalski <grochoge>
Wed 10 Apr 2024 08:09:58 PM UTC, comment #1: 

Windows Sockets can sometimes behave in a very unique way. We are trying to follow the opengroup sockets standards. Linux follows them better than Windows, can you please test how Linux behaves in this situation?

Simon Goldschmidt <goldsimon>
Group administrator
Wed 10 Apr 2024 07:02:45 PM UTC, original submission:  

I'm porting an existing application that sends multicast traffic via the Berkley socket API (in this case on Windows) and running into an issue.

Example usage:
1. bind() to
2. sendto() to

Result in Windows:
Packet is sent out over interface to

Result in LWIP:

I see LWIP has the ability to bind to a specific interface, but does not do so with a normal bind() call.
I believe an option should be added to do so in a normal bind() call, returning an error if a netif with the bound address doesn't exist.

Matt Grochowalski <grochoge>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by matthiasdietrich (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by grochoge (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code