Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UDP Bind Problem on Linux Headless Server

Discussion in 'Multiplayer' started by stanleylo, Jul 1, 2015.

  1. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    hi, all.

    when linux Headless server is running. the process bind IPADDR_ANY by default.
    ex:
    upload_2015-7-1_12-16-13.png

    But, there are multiple IP addresses on my server, the IPADDR_ANY will cause server fail to reply.
    when server send replies to client, it cant specifying the source ip address.
    so, Is there any way to tell server bind specify the IP address before start?
     
    Last edited: Jul 1, 2015
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    I don't think so, the nic with the lowest number will use when you will call send. And Yes You can specify ip in AddHost function (if you use transport interface)
     
  3. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    thanks your reply.
    I mean UNET not Low level API.
    on server with multiple IP address, IPADDR_ANY will cause server's reply lost, client can't receive it.
     
  4. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Hm, it is strange a little bit. It doesn;t matter if it is UNET or not, setting ip in INADDR_ANY will use for sending network interface with lower number which has assigned ip and which is UP. Peer won't receive udp packet iff the peer network is not reachable from this interface (for example if1 belongs private netwrok, while iff2 belongs DMZ in this case any external client won't be reachable)

    Anyway, when you call NetworkingTransport.AddHost() function you can specify ip address:
    NetworkingTransport.AddHost( topology, 5555, "15.15.15.15" );
     
  5. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    After I made a udp proxy (bind all of the IP address) to receive data from each IP address and forwarding packets to Linux headless server which is bind IPADDR_ANY. Then game can work properly.
     
    Last edited: Jul 3, 2015
  6. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    let's imagine this situation:
    upload_2015-7-3_20-16-28.png
    but, If Unity can provide an API to bind address for setting the UDP . It would be great
     
  7. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    upload_2015-7-3_20-31-0.png
    only two parameters?
     
  8. stanleylo

    stanleylo

    Joined:
    Jun 24, 2015
    Posts:
    7
    Yes. I found this overloaded API with three parameters and can specify the IP string .
    After call AddHost with our IP address, it can bind the IP address and listening like this:

    upload_2015-7-3_21-47-9.png

    but, it looks like for custom data communications, and nor for game state synchronization.
    The headless server still use IPADDR_ANY for client cmd/rpc I think.
    after headless server process started. client still cant get reply and show some error below:

    upload_2015-7-3_21-43-4.png