Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to get NetworkEndPoint of remote host after server accepts connection?

Discussion in 'Unity Transport' started by adamwilks, Oct 19, 2022.

  1. adamwilks

    adamwilks

    Joined:
    Apr 3, 2017
    Posts:
    23
    On the server side after calls to driver bind, listen, and accept have been successfully made I will be returned a NetworkConnection for a connected client, however that structure appears to store no information about the remote host address or port.

    Presumably this information is stored internally though in order to map inbound UDP packets to connections, so is it possible to get a NetworkEndPoint structure for the connection somehow?
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    359
    Yes,
    NetworkDriver.RemoteEndPoint
    can be used to get the remote endpoint of a connection.
     
    adamwilks likes this.
  3. adamwilks

    adamwilks

    Joined:
    Apr 3, 2017
    Posts:
    23
    The documentation doesn't have a description for what that method does but it's the one I was looking for and it seems completely obvious now, thanks!
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    359
    Yes, our documentation can certainly be improved. That's something we're working on.