How to identify client connection (TCP Socket)
- From: vlad <maxima@xxxxxxxx>
- Date: Thu, 16 Mar 2006 15:57:59 +0000 (UTC)
Hi.
Is there recommended practice to identify incoming TCP connections?
For instance. My app has several threads each has connection to server. Each of them transfer different type of data. So I'd like to keep them separate (also to dont mix up fragmented TCP packets).
I stuck on implementation of effective identification system. How to assign server working socket to corresponding thread.
After all I have to get the figure below :
Client:
- thread 1. socket.localendpoint = 192.168.0.100:2050
- thread 2. socket.localendpoint = 192.168.0.100:2051
Server:
- thread 1. workingSocket.remoteendpoint = 207.x.x.x:2050 <- real ip and same port
- thread 2. workingSocket.remoteendpoint = 207.x.x.x:2051
Question 1: How properly (and in most simple way) implement handshake between server and client to let server identify valid connection and reject strangers.
Question 2: When client connects under private address (192.168.x) then server outside will see real ip of private network gateway (say 207.x). Is it true that client application will always present outside 207.x.x.x address and not 207.x.x.y (is it possible for gateway to have more than 1 WAN interface ?) ?
I mean how persistent and reliable would be identification by gateway's address ??
Question 2.1: even in case of 3-stage handshake - I dont understand - how to tell server which port will open client. I know that client socket gets port number on socket.BeginConnect.... means that it is too late to tell server this port number as it is about to connect server.........
Looks like server has to accept any connection and then wait for confirmation with port number from client (before start send/receive on this socket).... ??? dont like the idea really...
Any thoughts on that ?
Cheers
P.S. I use C# 2.0 but can read C++ code. Just need a logical solution...
.
- Follow-Ups:
- Prev by Date: Re: The reason why SIO_RCVALL fails to capture outgoing packets on some systems.
- Next by Date: Re: Zero Config API
- Previous by thread: Zero Config API
- Next by thread: Re: How to identify client connection (TCP Socket)
- Index(es):
Relevant Pages
|