TCPListener - question about sockets 
Author Message
 TCPListener - question about sockets

I have a couple little programs that I've been using to
test some client/server functions.  Obviously, one program
functions as a server and the other functions as a client.

The server listens to port 25000 for incoming client
connections using a TCPListener.  When a client connects,
any data sent from the client to the server is bounced
back to the client.  Nothing big here, just using them to
figure some things out.  The server accepts the
connections using TCPListener.AcceptSocket.

Here's the interesting part:
Say I have clients A, B, and C connected to the server.  
The way I understand sockets, I would think that if the
server is listening to 25000, any incoming connections
would be redirected to a new port (say 25001 or something)
so that 25000 could stay open to receive new connections.  
However, if I run netstat and view all open connections,
it looks kind of like this:

127.0.0.1:3450 -> 127.0.0.1:25000
127.0.0.1:3451 -> 127.0.0.1:25000
127.0.0.1:3452 -> 127.0.0.1:25000

Basically, all of the clients are connected to port 25000
at the same time.  This doesn't make any sense to me
whatsoever since I thought that a new port had to be
opened for each client.  Maybe I'm just missing something,
so if anyone has an explaination, I'd appreciate it.  
Thanks in advance!



Tue, 28 Dec 2004 21:27:37 GMT  
 TCPListener - question about sockets

Quote:

>127.0.0.1:3450 -> 127.0.0.1:25000
>127.0.0.1:3451 -> 127.0.0.1:25000
>127.0.0.1:3452 -> 127.0.0.1:25000

>Basically, all of the clients are connected to port 25000
>at the same time.  This doesn't make any sense to me
>whatsoever since I thought that a new port had to be
>opened for each client.  Maybe I'm just missing something,
>so if anyone has an explaination, I'd appreciate it.  

A TCP connection is identified by the _pair_ of endpoints involved, that's how
the 25000 can be used more than once.

--

*--------={ Fine Art for .NET }=--------*

*---------------------------------------*

       Turn on, tune in, download.



Wed, 29 Dec 2004 00:40:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. System.NET, System.Net.Sockets -> TCPListener Issue

2. System.NET, System.Net.Sockets -> TCPListener Issue

3. Trouble with System.Net.Sockets.Socket under Windows 98

4. System.Net.Sockets.Socket Problem

5. System.Net.Sockets.Socket State

6. system.net.sockets.socket async server example

7. Detect Remote Disconnection System.Net.Sockets.Socket

8. System.Net.Sockets.Socket.EndReceive has a bogus return value

9. VB.NET and sockets question

10. Asynchronous Socket thread safty question.

11. tcpClient and sockets question

12. Socket Question

 

 
Powered by phpBB® Forum Software