kerryjiang / SuperSocket

SuperSocket is a light weight, cross platform and extensible socket server application framework.
Apache License 2.0
3.91k stars 1.15k forks source link

RemoteEndPoint Question #744

Closed alberk8 closed 1 month ago

alberk8 commented 1 month ago

I am a bit confused with the RemoteEndPoints. It looks like session.RemoteEndPoint is the IP of the Client/Remote IP and the session.Connection.RemoteEndPoint is the SuperSocket Endpoint IP. Is this correct?

.UsePackageHandler(async (session, package) =>
{
  Console.WriteLine($"Server EndPioint {((IPEndPoint)session.RemoteEndPoint).Address.ToString()} Client EndPoint {((IPEndPoint)session.Connection.RemoteEndPoint).Address.ToString()} ");
}
alberk8 commented 1 month ago

In my opinion, we need to have clear separation for the IP. One is the source IP (connecting Client IP) and the other is the IP of the Supersocket instance. The definition has to be clear from the client and server perspective (source vs target).

kerryjiang commented 1 month ago

Session stands for a connection in server side, so session's RemoteEndPoint is the client's endpoint. Session's local endpoint is the server listening endpoint.

Yes, it seems much clearer if we use source/destination for the scenario client => server. But we also need to think about scenario server => client (SuperSocket server side initiates connections to clients). For both scenarios, most of things are same except which side initiates the connection. So source/destination might not be an accurate term all the time.

alberk8 commented 1 month ago

So the session.RemoteEndPoint and the session.Connection.RemoteEndPoint should be refer to the same EndPoint?.

kerryjiang commented 1 month ago

session.Connection.RemoteEndPoint should be from socket directly, but session.RemoteEndPoint may use source endpoint from proxy info. You can consider session.RemoteEndPoint as remote endpoint on the application level.