471,354 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Determine dynamically assigned port of accepted server socket

After a server accepts a client connection on a certain port, a new socket is
created on the server on a system managed dynamic port to handle the
connection. Please confirm this.

If so, how can I get the number of the dynamic port in the server (in server
code)? Using LocalEndPoint.Port just returns the original listener port
number.

Thanks,

Jason
Jul 27 '05 #1
5 3852

http://msdn.microsoft.com/library/de...pointtopic.asp
Erick Sgarbi
After a server accepts a client connection on a certain port, a new
socket is created on the server on a system managed dynamic port to
handle the connection. Please confirm this.

If so, how can I get the number of the dynamic port in the server (in
server code)? Using LocalEndPoint.Port just returns the original
listener port number.

Thanks,

Jason

Jul 28 '05 #2
No, I don't need the client's port number, I need the server's new port
number for that instance socket.

Jason

"er***@csharpbox.com" wrote:

http://msdn.microsoft.com/library/de...pointtopic.asp
Erick Sgarbi
After a server accepts a client connection on a certain port, a new
socket is created on the server on a system managed dynamic port to
handle the connection. Please confirm this.

If so, how can I get the number of the dynamic port in the server (in
server code)? Using LocalEndPoint.Port just returns the original
listener port number.

Thanks,

Jason


Jul 28 '05 #3
Hi,

"Jason" <Ja***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
After a server accepts a client connection on a certain port, a new socket
is
created on the server on a system managed dynamic port to handle the
connection. Please confirm this.
No, that's not true. It creates a new Socket but keeps using the same port.
A TCP server can have multiple client connections to the same port.
HTH,
Greetings

If so, how can I get the number of the dynamic port in the server (in
server
code)? Using LocalEndPoint.Port just returns the original listener port
number.

Thanks,

Jason

Jul 28 '05 #4
Well then how does the server (underneath) resolve which socket steam should
recieve incoming packets? I thought this was done by creating the instance
socket on the server with a new port in the system managed dynamic port range.

Thanks,

Jason

"Bart Mermuys" wrote:
Hi,

"Jason" <Ja***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
After a server accepts a client connection on a certain port, a new socket
is
created on the server on a system managed dynamic port to handle the
connection. Please confirm this.


No, that's not true. It creates a new Socket but keeps using the same port.
A TCP server can have multiple client connections to the same port.
HTH,
Greetings

If so, how can I get the number of the dynamic port in the server (in
server
code)? Using LocalEndPoint.Port just returns the original listener port
number.

Thanks,

Jason


Jul 28 '05 #5
Hi,

"Jason" <Ja***@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...
Well then how does the server (underneath) resolve which socket steam
should
recieve incoming packets?
When there are multiple connections to the same server ip and server port ,
then either the client's ip or client's port is different or both.
Underneath it not only uses server ip and port but also client ip and port
to resolve the right Socket.
I thought this was done by creating the instance
socket on the server with a new port in the system managed dynamic port
range.
No, it's not, if you use windows you can use the commandline tool 'netstat'
to see that the _same_ server port is used when you have accepted a number
of connections.

For detailed explaining i can only recommend reading the RFC's about the TCP
protocol.

hth,
Greetings

I thought this was done by creating the instance
socket on the server with a new port in the system managed dynamic port
range.

Thanks,

Jason

"Bart Mermuys" wrote:
Hi,

"Jason" <Ja***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> After a server accepts a client connection on a certain port, a new
> socket
> is
> created on the server on a system managed dynamic port to handle the
> connection. Please confirm this.


No, that's not true. It creates a new Socket but keeps using the same
port.
A TCP server can have multiple client connections to the same port.
HTH,
Greetings
>
> If so, how can I get the number of the dynamic port in the server (in
> server
> code)? Using LocalEndPoint.Port just returns the original listener
> port
> number.
>
> Thanks,
>
> Jason


Jul 28 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dana Marcusanu | last post: by
4 posts views Thread by anketm | last post: by
7 posts views Thread by Sharon | last post: by
2 posts views Thread by jasonsgeiger | last post: by
15 posts views Thread by =?Utf-8?B?Vmlua2k=?= | last post: by
3 posts views Thread by Giampaolo Rodola' | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.