How to identify client connection (TCP Socket)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




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...


.



Relevant Pages

  • Re: Still cant connect to RWW or OWA remotely
    ... it certainly appears to be something about the SBS configuration. ... Meridian.local Ethernet adapter Local Area Connection: ... Windows SMALL BUSINESS SERVER 2003 Windows IP Configuration ... 192.168.254.254) directly to a port on the router and then ...
    (microsoft.public.windows.server.sbs)
  • Re: Passive means what during FTP?
    ... > server or the client that opens the data connection. ... the client tells the server what IP ... Vsftpd drops root after binding to port 21 entirely, ...
    (comp.os.linux.setup)
  • Re: Still cant connect to RWW or OWA remotely
    ... it certainly appears to be something about the SBS configuration. ... Meridian.local Ethernet adapter Local Area Connection: ... Windows SMALL BUSINESS SERVER 2003 Windows IP Configuration ... 192.168.254.254) directly to a port on the router and then ...
    (microsoft.public.windows.server.sbs)
  • Re: forwarded-tcpip vs. direct-tcpip
    ... "direct-tcpip" is initiated by the client at any time with no ... network connection to some address and port number, ... "forwarded-tcpip" is sent by the server to the client after the ...
    (comp.security.ssh)
  • Re: .Net Scalability problem
    ... LoadRunner will peak out a server with a few virtual users. ... To get an idea of load, ... Fire off the test client and watch the number of ... > So I think that the MTC generate concurrent connection and per ...
    (microsoft.public.dotnet.framework.adonet)