473,756 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.P ort just returns the original listener port
number.

Thanks,

Jason
Jul 27 '05 #1
5 4039

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.P ort 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***@csharpbo x.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.P ort just returns the original
listener port number.

Thanks,

Jason


Jul 28 '05 #3
Hi,

"Jason" <Ja***@discussi ons.microsoft.c om> wrote in message
news:6D******** *************** ***********@mic rosoft.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.P ort 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***@discussi ons.microsoft.c om> wrote in message
news:6D******** *************** ***********@mic rosoft.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.P ort just returns the original listener port
number.

Thanks,

Jason


Jul 28 '05 #5
Hi,

"Jason" <Ja***@discussi ons.microsoft.c om> wrote in message
news:C7******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c om> wrote in message
news:6D******** *************** ***********@mic rosoft.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.P ort just returns the original listener
> port
> number.
>
> Thanks,
>
> Jason


Jul 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2171
by: Dana Marcusanu | last post by:
Yes. I want to write a very small web sniffer that gets data from a specified port. I already looked at some of the existing ones on Internet, but they are not in Python (I am trying to learn Python!) and they have a lot more features that I want. Thanks for your suggestion. I will check out pcap library. Dana On 2005-02-01, Dana Marcusanu <dmarcus...@yahoo.com> wrote:
4
1825
by: anketm | last post by:
I am writing a simple client using UDP sockets. I am wondering if there is any way to determine what local port a socket was bound to when bind() is not explicitly called. This is what my program looks like: sock = socket(PF_INET, SOCK_DGRAM, 0); sendto(sock, message, strlen(message) + 1, 0, (struct sockaddr *) &server, sizeof(server));
5
726
by: Jason | last post by:
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,
6
2302
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine, where my browser resides. Browser would be IE, O.S. Windows 2000 or XP, and it's for an intranet application. The goal of the little server on the localhost client side would be to trigger a scanner, with the TWAIN library. Also this server is...
7
7569
by: Sharon | last post by:
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...
2
7126
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...
15
20744
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);
3
2236
by: Giampaolo Rodola' | last post by:
Hi there, since the socket.socket.family attribute has been introduced only in Python 2.5 and I need to have my application to be backward compatible with Python 2.3 and 2.4 I'd like to know how could I determine the family of a socket.socket instance which may be AF_INET or AF_INET6. Is there some kind of getsockopt() directive I could use? For now I've been able to determine the family by using: # self.socket = a connected...
1
4477
by: kash123 | last post by:
Hi All, I have written an application, a part of which, in the application, is a socket server programe accepting connection requests from socket clients. My server code typically contains, a call to socket, bind, listen, accept and later read and write using the accept file descriptor (fd). The client socket prog is so designed (who ever did so!) that every certain time period it closes the connection with the server and reconnects...
0
9325
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
9930
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...
0
9571
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8569
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7116
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
4996
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3676
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
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2542
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.