maxima
2006-03-16 15:31:29 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
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