Recent

Author Topic: LazWebsocket How to identify IP adress during connect  (Read 254 times)

hgbk

  • New member
  • *
  • Posts: 8
LazWebsocket How to identify IP adress during connect
« on: April 20, 2021, 03:47:09 pm »
I have implemented a game as client server solution using LazWebsockets. It may happen that during the game the connection from a client breaks. In order to implement the possibility for this specific client to reconnect I need to identify the IP address during accept and compare it with ACommunication.SocketStream.RemoteAddress.Address of this client  which I have stored before failure. In accept I have TRequestData as parameter which delivers Host (Domain but not IP address). Any idea how to solve this?

Warfley

  • Sr. Member
  • ****
  • Posts: 449
Re: LazWebsocket How to identify IP adress during connect
« Reply #1 on: April 21, 2021, 03:02:55 am »
There is currently no way implemented to identify the client during the handshake. This is defenetly something I will consider adding to the library.

But, I should point out that identifying clients based on their IPs is bad style, as due to the use of NAT networks, multiple devices usually share an external IP. While in Europe and the US it is usually something like one per household, for some (cheaper) internet providers or providers in other countries that haven't been so lucky with getting large shares of the IP address space, multiple homes or even larger parts like city blocks can share the same IP address. So there could be potentially hundreds of people with the same IP.

Therefore you should give the client a unique ID to reconnect. Like when a game starts, you could generate a game ID, which every client gets. If a client looses it's connection it can reconnect by sending this game ID to the server and the server can recognize this and put it back into the right game

hgbk

  • New member
  • *
  • Posts: 8
Re: LazWebsocket How to identify IP adress during connect
« Reply #2 on: April 21, 2021, 01:17:49 pm »
Understand - I will implement the "reconnect" according to your proposal. Thanks a lot for the quick and helpful answer!

 

TinyPortal © 2005-2018