By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,828 Members | 801 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,828 IT Pros & Developers. It's quick & easy.

Multiple connections, same port

P: n/a
Hi all,
I've implemented a TCP server using the Socket async methods.
When connecting to the server from 3 instances of hyper terminal,
i've noticed that each of the newly created server sockets, uses the same
server port.
I assumed that a new connection will receive a unique port.
If this is the way its suppose to work, is it a performance issue?
Is it possible that connections from the same IP will connect on the same
server port?
I have no way to test it, as i have only one computer.
Thanks,
Sharon.
Mar 1 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Yes. Your server listens on same port, but the sockets are unique (client
IP, client port, srv IP, srv Port).

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
| Hi all,
| I've implemented a TCP server using the Socket async methods.
| When connecting to the server from 3 instances of hyper terminal,
| i've noticed that each of the newly created server sockets, uses the same
| server port.
| I assumed that a new connection will receive a unique port.
| If this is the way its suppose to work, is it a performance issue?
| Is it possible that connections from the same IP will connect on the same
| server port?
| I have no way to test it, as i have only one computer.
| Thanks,
| Sharon.
|
|
Mar 1 '06 #2

P: n/a
Hello William, and thanks for your reply.
The listener socket always listens on the same port,
but shouldn't a new worker socket be given a unique server port?
In my app all clients use the same server listener port.
In all examples i've seen about Socket async methods (BeginAccept,
EndAccept),
there is no attempt to switch the client port.
Am i doing something wrong?
By "yes" you mean that this is the way it should work?
Sharon.

"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:ux*************@TK2MSFTNGP15.phx.gbl...
Yes. Your server listens on same port, but the sockets are unique (client
IP, client port, srv IP, srv Port).

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
| Hi all,
| I've implemented a TCP server using the Socket async methods.
| When connecting to the server from 3 instances of hyper terminal,
| i've noticed that each of the newly created server sockets, uses the
same
| server port.
| I assumed that a new connection will receive a unique port.
| If this is the way its suppose to work, is it a performance issue?
| Is it possible that connections from the same IP will connect on the
same
| server port?
| I have no way to test it, as i have only one computer.
| Thanks,
| Sharon.
|
|

Mar 1 '06 #3

P: n/a
Yes, that is way it should work. Your client's would not know where to
connect if the port keeps changing on the server. As I said, there are 4
pieces of information that make up a unique socket. only 1 has to be
different per socket. So the same client can connect multiple times to the
same server port as long as the client ports or different (dynamic). Many
clients can connect to same server port because they all have different IPs,
etc. SMTP is port 25, DNS is 53 - they use wellknown server ports. Does
that help?

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:ed**************@TK2MSFTNGP15.phx.gbl...
| Hello William, and thanks for your reply.
| The listener socket always listens on the same port,
| but shouldn't a new worker socket be given a unique server port?
| In my app all clients use the same server listener port.
| In all examples i've seen about Socket async methods (BeginAccept,
| EndAccept),
| there is no attempt to switch the client port.
| Am i doing something wrong?
| By "yes" you mean that this is the way it should work?
| Sharon.
|
|
|
| "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| news:ux*************@TK2MSFTNGP15.phx.gbl...
| > Yes. Your server listens on same port, but the sockets are unique
(client
| > IP, client port, srv IP, srv Port).
| >
| > --
| > William Stacey [MVP]
| >
| > "Sharon" <no*****@null.void> wrote in message
| > news:eD**************@TK2MSFTNGP12.phx.gbl...
| > | Hi all,
| > | I've implemented a TCP server using the Socket async methods.
| > | When connecting to the server from 3 instances of hyper terminal,
| > | i've noticed that each of the newly created server sockets, uses the
| > same
| > | server port.
| > | I assumed that a new connection will receive a unique port.
| > | If this is the way its suppose to work, is it a performance issue?
| > | Is it possible that connections from the same IP will connect on the
| > same
| > | server port?
| > | I have no way to test it, as i have only one computer.
| > | Thanks,
| > | Sharon.
| > |
| > |
| >
| >
|
|
Mar 2 '06 #4

P: n/a
A TCP connection is a 4-tuple

(server addr,server port,client addr,client port)

Therefore it is not a problem to have multiple clients connecting to the
same server port.

This is effectively enforced at the client end where you will not be able to
bind 2 client sockets to the same address and port(normally you just accept
the default anyway which just allocates the next port).

"Sharon" <no*****@null.void> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
Hi all,
I've implemented a TCP server using the Socket async methods.
When connecting to the server from 3 instances of hyper terminal,
i've noticed that each of the newly created server sockets, uses the same
server port.
I assumed that a new connection will receive a unique port.
If this is the way its suppose to work, is it a performance issue?
Is it possible that connections from the same IP will connect on the same
server port?
I have no way to test it, as i have only one computer.
Thanks,
Sharon.

Mar 2 '06 #5

P: n/a
Ok, there is one more thing that is not clear to me.
If 2 clients are connected on the same server ip & port,
what happens when both clients try to send data at the same time?
One of them waits until the other has finished sending?
Thanks,
Sharon.
"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:uC**************@TK2MSFTNGP14.phx.gbl...
Yes, that is way it should work. Your client's would not know where to
connect if the port keeps changing on the server. As I said, there are 4
pieces of information that make up a unique socket. only 1 has to be
different per socket. So the same client can connect multiple times to
the
same server port as long as the client ports or different (dynamic). Many
clients can connect to same server port because they all have different
IPs,
etc. SMTP is port 25, DNS is 53 - they use wellknown server ports. Does
that help?

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:ed**************@TK2MSFTNGP15.phx.gbl...
| Hello William, and thanks for your reply.
| The listener socket always listens on the same port,
| but shouldn't a new worker socket be given a unique server port?
| In my app all clients use the same server listener port.
| In all examples i've seen about Socket async methods (BeginAccept,
| EndAccept),
| there is no attempt to switch the client port.
| Am i doing something wrong?
| By "yes" you mean that this is the way it should work?
| Sharon.
|
|
|
| "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| news:ux*************@TK2MSFTNGP15.phx.gbl...
| > Yes. Your server listens on same port, but the sockets are unique
(client
| > IP, client port, srv IP, srv Port).
| >
| > --
| > William Stacey [MVP]
| >
| > "Sharon" <no*****@null.void> wrote in message
| > news:eD**************@TK2MSFTNGP12.phx.gbl...
| > | Hi all,
| > | I've implemented a TCP server using the Socket async methods.
| > | When connecting to the server from 3 instances of hyper terminal,
| > | i've noticed that each of the newly created server sockets, uses the
| > same
| > | server port.
| > | I assumed that a new connection will receive a unique port.
| > | If this is the way its suppose to work, is it a performance issue?
| > | Is it possible that connections from the same IP will connect on the
| > same
| > | server port?
| > | I have no way to test it, as i have only one computer.
| > | Thanks,
| > | Sharon.
| > |
| > |
| >
| >
|
|

Mar 2 '06 #6

P: n/a
No, they can both send. Remember that have different sockets on the server.
Tcp handles the retry logic, so it is not something you normally have to
deal with.

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
| Ok, there is one more thing that is not clear to me.
| If 2 clients are connected on the same server ip & port,
| what happens when both clients try to send data at the same time?
| One of them waits until the other has finished sending?
| Thanks,
| Sharon.
|
|
| "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| news:uC**************@TK2MSFTNGP14.phx.gbl...
| > Yes, that is way it should work. Your client's would not know where to
| > connect if the port keeps changing on the server. As I said, there are
4
| > pieces of information that make up a unique socket. only 1 has to be
| > different per socket. So the same client can connect multiple times to
| > the
| > same server port as long as the client ports or different (dynamic).
Many
| > clients can connect to same server port because they all have different
| > IPs,
| > etc. SMTP is port 25, DNS is 53 - they use wellknown server ports.
Does
| > that help?
| >
| > --
| > William Stacey [MVP]
| >
| > "Sharon" <no*****@null.void> wrote in message
| > news:ed**************@TK2MSFTNGP15.phx.gbl...
| > | Hello William, and thanks for your reply.
| > | The listener socket always listens on the same port,
| > | but shouldn't a new worker socket be given a unique server port?
| > | In my app all clients use the same server listener port.
| > | In all examples i've seen about Socket async methods (BeginAccept,
| > | EndAccept),
| > | there is no attempt to switch the client port.
| > | Am i doing something wrong?
| > | By "yes" you mean that this is the way it should work?
| > | Sharon.
| > |
| > |
| > |
| > | "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| > | news:ux*************@TK2MSFTNGP15.phx.gbl...
| > | > Yes. Your server listens on same port, but the sockets are unique
| > (client
| > | > IP, client port, srv IP, srv Port).
| > | >
| > | > --
| > | > William Stacey [MVP]
| > | >
| > | > "Sharon" <no*****@null.void> wrote in message
| > | > news:eD**************@TK2MSFTNGP12.phx.gbl...
| > | > | Hi all,
| > | > | I've implemented a TCP server using the Socket async methods.
| > | > | When connecting to the server from 3 instances of hyper terminal,
| > | > | i've noticed that each of the newly created server sockets, uses
the
| > | > same
| > | > | server port.
| > | > | I assumed that a new connection will receive a unique port.
| > | > | If this is the way its suppose to work, is it a performance issue?
| > | > | Is it possible that connections from the same IP will connect on
the
| > | > same
| > | > | server port?
| > | > | I have no way to test it, as i have only one computer.
| > | > | Thanks,
| > | > | Sharon.
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Mar 2 '06 #7

P: n/a
All clear, thanks a bunch.
Sharon.

"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:ed*************@tk2msftngp13.phx.gbl...
No, they can both send. Remember that have different sockets on the
server.
Tcp handles the retry logic, so it is not something you normally have to
deal with.

--
William Stacey [MVP]

"Sharon" <no*****@null.void> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
| Ok, there is one more thing that is not clear to me.
| If 2 clients are connected on the same server ip & port,
| what happens when both clients try to send data at the same time?
| One of them waits until the other has finished sending?
| Thanks,
| Sharon.
|
|
| "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| news:uC**************@TK2MSFTNGP14.phx.gbl...
| > Yes, that is way it should work. Your client's would not know where to
| > connect if the port keeps changing on the server. As I said, there
are
4
| > pieces of information that make up a unique socket. only 1 has to be
| > different per socket. So the same client can connect multiple times
to
| > the
| > same server port as long as the client ports or different (dynamic).
Many
| > clients can connect to same server port because they all have
different
| > IPs,
| > etc. SMTP is port 25, DNS is 53 - they use wellknown server ports.
Does
| > that help?
| >
| > --
| > William Stacey [MVP]
| >
| > "Sharon" <no*****@null.void> wrote in message
| > news:ed**************@TK2MSFTNGP15.phx.gbl...
| > | Hello William, and thanks for your reply.
| > | The listener socket always listens on the same port,
| > | but shouldn't a new worker socket be given a unique server port?
| > | In my app all clients use the same server listener port.
| > | In all examples i've seen about Socket async methods (BeginAccept,
| > | EndAccept),
| > | there is no attempt to switch the client port.
| > | Am i doing something wrong?
| > | By "yes" you mean that this is the way it should work?
| > | Sharon.
| > |
| > |
| > |
| > | "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| > | news:ux*************@TK2MSFTNGP15.phx.gbl...
| > | > Yes. Your server listens on same port, but the sockets are unique
| > (client
| > | > IP, client port, srv IP, srv Port).
| > | >
| > | > --
| > | > William Stacey [MVP]
| > | >
| > | > "Sharon" <no*****@null.void> wrote in message
| > | > news:eD**************@TK2MSFTNGP12.phx.gbl...
| > | > | Hi all,
| > | > | I've implemented a TCP server using the Socket async methods.
| > | > | When connecting to the server from 3 instances of hyper
terminal,
| > | > | i've noticed that each of the newly created server sockets, uses
the
| > | > same
| > | > | server port.
| > | > | I assumed that a new connection will receive a unique port.
| > | > | If this is the way its suppose to work, is it a performance
issue?
| > | > | Is it possible that connections from the same IP will connect on
the
| > | > same
| > | > | server port?
| > | > | I have no way to test it, as i have only one computer.
| > | > | Thanks,
| > | > | Sharon.
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|

Mar 2 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.