From: "Factor" <ja**********@gmail.com>
Newsgroups: microsoft.public.in.csharp
Subject: Multiple Clients, One port
Date: Wed, 19 Apr 2006 09:36:02 -0700
I'm been working with sockets for a short while now using a server
program a former coworker started. The program listens on a port for
incomming connections. When a valid connection is made (we send this
init string into the socket from the clients) the server closes the
socket so it can start listening on that port again for other clients
and starts a new thread that contacts the client back on some random
outgoing server port. Maybe this seems stupid, but at the time we
thought there was no way to have multiple connections on one port at a
time.
Then we started thinking about it. FTP, SMTP. These all operate on
standard ports and handle multiple simultanious clients/connections.
How is this done? My curiosity never peek enough to actually try to
code it.
Fortunately/Unfortunately, the time has come for me to impliment
something like this - not because I'm just curious - but because the
clients are soon be heavily firewalled and I will not be able to have
the server "contact them back" like we are doing now. I have to figure
out how to get the clients to log into this port on the server, and not
block out all other clients while they are communicating. Sessions are
often only a few seconds long but they CAN be up to an hour (we're
doing work over the cellular network, it's very slow and roundtrip
latency cane be up to two seconds! Yikes!) If I have a client logged
in for 45 minutes it cannot be blocking that port for all other clients
for that time.
So to my question: Am I attempting the impossible? How do I go about
doing this? Does anyone know of any resources that I can read online
or purchase(books, CDs) to help me get started with this multiple
clients on one port application? Am I incorrect about thinking that
one port can handle more than one connection (if so, then how does
SMTP, POP3, FTP, or any other common port server function)?
I've found very little out there on the internet... anyone have any
sugestions?
I can post cost if necessary, but since I'm really looking for help on
new nonexistant code, then I'm not sure what good it would do anyone.
I thank you all ahead of time for any help I receive. Thank you for you
time,
Jason
P.S. I know I can come up with some scheme that the client logs in and
then i send it back a port number from a known pool on my server. Then
the client can log out and then log back into that port. This seems
Sockets: messy and unnecessary. It'd rather try to make it work all on
one port.