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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

LLAPI questions.

Discussion in 'Multiplayer' started by LastDude, Aug 5, 2015.

  1. LastDude

    LastDude

    Joined:
    Aug 5, 2015
    Posts:
    15
    Hi. I'm looking through the LLAPI and I have some questions:

    Why does NetworkTransport.Connect() need a hostId (the first argument)?
    Do I need to call NetworkTransport.AddHost() even for a (pure) client? (Maybe this should be called CreateSocket()?!)
    Why do I have to pass the BufferSize to NetworkTransport.Receive()

    That's all I can remember for now. Thanks.
     
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    1. From network view you need to open udp socket to be able send and receive something to/from internet, correct? Library need to know what socket it should use when you are going to send data. AddHost() - internally will open udp socket. Connect() should point to the socket which are you going to use.

    NetworkTransport.Receive() - internally have a buffer with received data, this buffer belongs to library not to you, so You need provide your buffer for data.
     
  3. LastDude

    LastDude

    Joined:
    Aug 5, 2015
    Posts:
    15
    Thanks, I wasn't sure what host meant (the naming is a little weird).

    I have a couple more questions:

    How does ConnectAsNetworkHost() works and what is the correct way to use it?
    How to use this ReceiveFromHost() together with ConnectAsNetworkHost()?
    Should I use Receive() together with ReceiveFromHost()?
    What is this ReceiveRelayEventFromHost()?
     
  4. ian_facepunch

    ian_facepunch

    Joined:
    Mar 16, 2015
    Posts:
    22
    I'd also like to know how ConnectAsNetworkHost() works. I'd like if possible to use the Matchmaker and relay server with LLAPI.