473,890 Members | 1,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7593
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.v oid> wrote in message
news:eD******** ******@TK2MSFTN GP12.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******** *****@TK2MSFTNG P15.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.v oid> wrote in message
news:eD******** ******@TK2MSFTN GP12.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.v oid> wrote in message
news:ed******** ******@TK2MSFTN GP15.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******** *****@TK2MSFTNG P15.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.v oid> wrote in message
| > news:eD******** ******@TK2MSFTN GP12.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.v oid> wrote in message
news:eD******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP14.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.v oid> wrote in message
news:ed******** ******@TK2MSFTN GP15.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******** *****@TK2MSFTNG P15.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.v oid> wrote in message
| > news:eD******** ******@TK2MSFTN GP12.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.v oid> wrote in message
news:eC******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP14.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.v oid> wrote in message
| > news:ed******** ******@TK2MSFTN GP15.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******** *****@TK2MSFTNG P15.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.v oid> wrote in message
| > | > news:eD******** ******@TK2MSFTN GP12.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******** *****@tk2msftng p13.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.v oid> wrote in message
news:eC******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP14.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.v oid> wrote in message
| > news:ed******** ******@TK2MSFTN GP15.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******** *****@TK2MSFTNG P15.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.v oid> wrote in message
| > | > news:eD******** ******@TK2MSFTN GP12.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
2504
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 System.Net.Sockets about multiple sockets on the same port. This happens even with a single listener in multiple Win32 processes. Will I get better results by using a Socket instance with BeginAccept? Should I run multiple threads, or do the asynchronous...
0
1266
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 the database. We have a problem with JDBC connections though. We have an application thatuses Resin and connects to the database via a jdbc driver. When we use, for example:
3
9108
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 how separate threads can communicate directly. Any techniques I can use? Thanks! //LISTENER THREAD class Server { static void Main(string args)
6
4452
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 handles multiple connections. Client programs will make a connection and pass text strings to the service, which will then return a value for each of the strings. It's unlikely the service will ever have more than 100 simultaneous connections and...
2
7137
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 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...
4
10170
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. Also, I need the service to accept multiple incoming requests. Here is the code: public void Listen() { #region Commented Code
35
9381
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 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
15
20776
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 code Int32 port = Int32.Parse(ConfigurationManager.AppSettings);
4
6550
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 client and as I was asked to develop to listen on multiple ports handling multiple clients, I am stuck with out a solution. The below is what could end up doing any help to solve the problem will be very much appreciated. Below is the code I...
0
9978
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9820
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10922
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8016
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3276
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.