Author Topic: Port already in use, possible?  (Read 2783 times)

iddqd

  • Guest
Port already in use, possible?
« on: March 15, 2013, 04:47:21 AM »
Hi

It seems like I have to define a port for my application (UDP only, LAN only), at least for the lobby connection. Is it possible that this port is taken by another application on the network in which case i would always have to implement the possibility to change the port on my server/client/lobby connection. Or is this not the case with UDP? I haven't been able to find any info on this.

Obviously i would prefer not to have to tell the users "This port is used by another application, please change the port to ..." and i rarely see games nowadays that give the user this option.

Many thanks for your asset!

iddqd

  • Guest
Re: Port already in use, possible?
« Reply #1 on: March 16, 2013, 02:45:41 AM »
To simplify my question: is it possible that the lobby port is already in use by another application?  ::)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Port already in use, possible?
« Reply #2 on: March 16, 2013, 09:10:09 AM »
No, only one app can use a port at a time. For example if you have a TNServer running that listens to port 5129, launching a TNServerInstance also listening to port 5129 will fail.

iddqd

  • Guest
Re: Port already in use, possible?
« Reply #3 on: March 16, 2013, 02:40:30 PM »
Many thanks for your answer.

So if I have a non unity application (lets say another gameserver) running on port 1111, then i cannot have my game start a server with the lobby on 1111? That would mean, that I cannot hardcode the lobby port into my application, since I can never be sure what other applications the user has running, correct?

I'm a bit confused because according to http://stackoverflow.com/questions/1694144/can-two-applications-listen-to-the-same-port it's apparently possible to have two applications on the same udp port, but apparently only multicast. Is the lobby multicast?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Port already in use, possible?
« Reply #4 on: March 16, 2013, 09:05:21 PM »
No, lobby is not using multicasting. The lobby server listens to a specific port. Clients broadcast requests to that port, and the lobby server responds. You can have multiple clients, you just can't have multiple servers on the same machine.

The way sockets work in general is once you bind a socket to a specific port, no other application can repeat the process until you close that socket.