Network: Spawning 2 UDP connections from TCP Rendez vous

Hello all,
Still struggling with my network code.
Basically, what i need is :
when server receive a connection on the special TCP rendez vous port,

instead of adding the connection (a tcp connection from the client )

 if cListener.newConnectionAvailable():

    rendezvous = PointerToConnection()
    netAddress = NetAddress()
    newConnection = PointerToConnection()

    if cListener.getNewConnection(rendezvous,netAddress,newConnection):
      newConnection = newConnection.p()
      activeConnections.append(newConnection) # Remember connection
      cReader.addConnection(newConnection) # Begin reading connection
  return Task.cont

it creates 2 bi-directionnal UDP connection to the client that requested connection.

ex Client 1 make a TCP Connection to Server .
Server create a UDP connection u1 between port1 of Client 1 and port X1 of server for sending / receiving data
Server create a UDP connection u2 between port2 of Client 1 and port X2 of server for sending / receiving data

1)Is it enough to for Client 1 to know server ip and Port X1,X2 to be able to create a u1_c UPD connection that listen and send on the u1 connection? or do i need a kind of handshake ?

  1. how do i create an UPD connection in Panda that can both send and receive packet. Is it enough to create 1 UPD connection and add it both on a QueuedConnectionReader and a QueuedConnectionWriter

  2. Can the connection rendez vous between client and server be initialized via a Client upd connection ? (from my understanding : NO)

Thanks for your input :slight_smile:

  1. no udp is connectionless so sending to a port on any computer that is most likey firewalled is just fine.

  2. yes they are bidirectional … i still cant figure out why you need 2 of them

  3. As in client send a UDP packet to server and connection starts? Well that is how they are normally started… Server sending client UDP packets generally don’t work … that is what you propose in 1.

Afaik, udp connections are not bidirectional, however you can just try to send a package back to where it came from. Most often this is blocked by a firewall. However most firewalls remember that you sent a package to a ip and allow responses.

Afaik panda3d handles udp connections as a hostadress, each time you send a package it uses the stored connection (hostname/ip & port) to define the recipient.

I might be completely wrong with all i wrote, but thats my experience :wink:

So it means that each “packet”/“datagram” knows from which IP and port he cames from?

So it would mean that i could setup one only UPD Port on server to receive from every Client and still be able to dispatch the packet to the right clients afterward?

Yes, that’s right. If you receive the packet with a NetDatagram, you can query the NetDatagram to find out where it came from.