Home Forums Support Can I send UDP to a specific adapter ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2778
    Anonymous
    Inactive

    I have a computer with several network adapters,
    and I need to send and listen to UDP packets on a specific adapter (which is not default).
    Is this possible with NetworkComms ?

    #2785
    Anonymous
    Inactive

    To listen on a specific adaptor for UDP use:

    //Select local host IP Address and port 10000
    IPEndPoint desiredLocalIPEndPoint = IPTools.ParseEndPointFromString("127.0.0.1:10000");
    
    //Create a UDP listener instance
    ConnectionListenerBase udpListener = new UDPConnectionListener(NetworkComms.DefaultSendReceiveOptions, ApplicationLayerProtocolStatus.Enabled, UDPConnection.DefaultUDPOptions);
    
    //Start listening
    Connection.StartListening(udpListener, desiredLocalIPEndPoint);

    Sending is currently handled by the operating system being used, we do have support for specific adaptor binding but it is not accessibly publicly at the moment. If you provide an example when this does not work we will of course consider extending the library to support this feature.

    Kind regards,
    Marc

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.