473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Multiple connections, same port

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
7 7510
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul A. Steckler | last post by:
I need to write a TCP/IP server in C# that can handle multiple connections. My first try was to use TCPListener instances in multiple .NET threads. Of course, I got an exception from...
0
by: Matthew Lunnon | last post by:
Hi all, We're running multiple PostgresQL database installations, each on a separate port. This works fine and psql -p <port number> template1 works and connects to the correct instance of...
3
by: Adam | last post by:
My telnet server app. creates a new thread for each incoming Tcp client as shown in the code below. How can the client threads send text messages back and forth to each other? I don't understand...
6
by: Quiet Man | last post by:
Hi all, I'm designing a fairly simple service that will run on W2K/SP4 and W2K3 servers. It's job is to be a very specialized database server that listens on a given IP address / TCP port and...
2
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@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...
4
by: sracherla | last post by:
I am trying to write a simple windows service that accepts an incoming request; receives a string input and sends a string output. I need this connection to stay alive until the client closes it....
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
15
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello everyone, I have this code for TCPListenPort. The code works fine, but my manager is asking me to establish multiple connections to the same port. How can i acheive that below is my...
4
by: Veeraraghavan | last post by:
Hi All, I am developing a client server communication using system.net.socket and I am finding it very difficult to get a solution for this. I started with single port communication with single...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.