I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a
different socket in listen mode? Using the dotnet framework, I create a
socket, bind it to a port, put it in listen mode, and then n sockets can
connect to it. The code:
Socket newSocket = listeningSocket.Accept();
returns a socket. I can communicate on newSocket, and listeningSocket goes
back to listen mode. Is newSocket using the port that I bound
listeningSocket to? If 5 clients connect to listeningSocket, and you check
the remote endpoint on each of them, they will all point to
listeningSocket's IP address and the same port. The 5 resulting newSockets
local endpoint properties all show the same port that listeningSocket is
bound to. Can many sockets all use the same port?
If this is the case, how come when I try to manually bind a some other
socket to the port that listeningSocket is listening on, I get a "port in
use" error?
So what happens behind the scenes? Does the newSocket use the same port
that listeningSocket is bound to? Or does it newSocket get "assigned" a
free port by the WSA code wrapped by the Socket class? When I check
newSocket's local endpoint property, it says the same port that
listeningSocket is bound to. How can multiple sockets be using the same
port? 4 2138
Each socket must be unique by 4 values:
IP Local, Port Local
IP Remote, Port Remote
When the listener accepts a new socket, it fills (among other things) that
socket object with those four values. That means no other socket can use
those same values, at least one must be different. So the same client can
not connect to the same server and port using the same local IP and port.
Clients normally get dynamic ports so that allows a client to connect to the
same server/port more then once. On the listening side, when you try to
listen to the same IP and port more then once, you get an error unless you
allow duplicates which is another can of worms. HTH
--
William Stacey [MVP]
"0to60" <ho****************@yahoo.com> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl... I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code:
Socket newSocket = listeningSocket.Accept();
returns a socket. I can communicate on newSocket, and listeningSocket goes back to listen mode. Is newSocket using the port that I bound listeningSocket to? If 5 clients connect to listeningSocket, and you check the remote endpoint on each of them, they will all point to listeningSocket's IP address and the same port. The 5 resulting newSockets local endpoint properties all show the same port that listeningSocket is bound to. Can many sockets all use the same port?
If this is the case, how come when I try to manually bind a some other socket to the port that listeningSocket is listening on, I get a "port in use" error?
So what happens behind the scenes? Does the newSocket use the same port that listeningSocket is bound to? Or does it newSocket get "assigned" a free port by the WSA code wrapped by the Socket class? When I check newSocket's local endpoint property, it says the same port that listeningSocket is bound to. How can multiple sockets be using the same port?
Additionally , as a server ( listen socket ) you can have 10 accepted
connections in XP ( look at http://support.microsoft.com/default...b;en-us;314882 )
Arkady
"William Stacey [MVP]" <st*****@mvps.org> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl... Each socket must be unique by 4 values: IP Local, Port Local IP Remote, Port Remote
When the listener accepts a new socket, it fills (among other things) that socket object with those four values. That means no other socket can use those same values, at least one must be different. So the same client can not connect to the same server and port using the same local IP and port. Clients normally get dynamic ports so that allows a client to connect to the same server/port more then once. On the listening side, when you try to listen to the same IP and port more then once, you get an error unless you allow duplicates which is another can of worms. HTH
-- William Stacey [MVP]
"0to60" <ho****************@yahoo.com> wrote in message news:OZ**************@TK2MSFTNGP09.phx.gbl...I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code:
Socket newSocket = listeningSocket.Accept();
returns a socket. I can communicate on newSocket, and listeningSocket goes back to listen mode. Is newSocket using the port that I bound listeningSocket to? If 5 clients connect to listeningSocket, and you check the remote endpoint on each of them, they will all point to listeningSocket's IP address and the same port. The 5 resulting newSockets local endpoint properties all show the same port that listeningSocket is bound to. Can many sockets all use the same port?
If this is the case, how come when I try to manually bind a some other socket to the port that listeningSocket is listening on, I get a "port in use" error?
So what happens behind the scenes? Does the newSocket use the same port that listeningSocket is bound to? Or does it newSocket get "assigned" a free port by the WSA code wrapped by the Socket class? When I check newSocket's local endpoint property, it says the same port that listeningSocket is bound to. How can multiple sockets be using the same port?
I saw this little line at the end of that article:
"Per development: The connection limit refers to the number of
redirector-based connections and is enforced for any file, print, named
pipe, or mail slot session. The TCP connection limit is not enforced, but it
may be bound by legal agreement to not permit more than 10 clients. "
So from my read, this does not apply to sockets, but to redirector-based
connections. Is this true? Easy to test, but have not done so myself.
--
William Stacey [MVP]
"Arkady Frenkel" <ar*****@hotmailxdotx.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... Additionally , as a server ( listen socket ) you can have 10 accepted connections in XP ( look at http://support.microsoft.com/default...b;en-us;314882 ) Arkady
"William Stacey [MVP]" <st*****@mvps.org> wrote in message news:eN**************@TK2MSFTNGP10.phx.gbl... Each socket must be unique by 4 values: IP Local, Port Local IP Remote, Port Remote
When the listener accepts a new socket, it fills (among other things) that socket object with those four values. That means no other socket can use those same values, at least one must be different. So the same client can not connect to the same server and port using the same local IP and port. Clients normally get dynamic ports so that allows a client to connect to the same server/port more then once. On the listening side, when you try to listen to the same IP and port more then once, you get an error unless you allow duplicates which is another can of worms. HTH
-- William Stacey [MVP]
"0to60" <ho****************@yahoo.com> wrote in message news:OZ**************@TK2MSFTNGP09.phx.gbl...I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code:
Socket newSocket = listeningSocket.Accept();
returns a socket. I can communicate on newSocket, and listeningSocket goes back to listen mode. Is newSocket using the port that I bound listeningSocket to? If 5 clients connect to listeningSocket, and you check the remote endpoint on each of them, they will all point to listeningSocket's IP address and the same port. The 5 resulting newSockets local endpoint properties all show the same port that listeningSocket is bound to. Can many sockets all use the same port?
If this is the case, how come when I try to manually bind a some other socket to the port that listeningSocket is listening on, I get a "port in use" error?
So what happens behind the scenes? Does the newSocket use the same port that listeningSocket is bound to? Or does it newSocket get "assigned" a free port by the WSA code wrapped by the Socket class? When I check newSocket's local endpoint property, it says the same port that listeningSocket is bound to. How can multiple sockets be using the same port?
Due to the next ( that that KB )
"All logical drive, logical printer, and transport level connections
combined from a single computer are considered to be one session; therefore,
these connections only count as one connection in the ten- connection limit.
For example, if a user establishes two logical drive connections, two
Windows sockets, and one logical printer connection to a Windows XP system,
one session is established. As a result, there will be only one less
connection that can be made to the Windows XP system, even though three
logical connections have been established." that not only SMB connections
but winsock too , but I didn't check that too ( have to bother 11 buddies
for that :) )
Arkady
"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl... I saw this little line at the end of that article: "Per development: The connection limit refers to the number of redirector-based connections and is enforced for any file, print, named pipe, or mail slot session. The TCP connection limit is not enforced, but it may be bound by legal agreement to not permit more than 10 clients. "
So from my read, this does not apply to sockets, but to redirector-based connections. Is this true? Easy to test, but have not done so myself.
-- William Stacey [MVP]
"Arkady Frenkel" <ar*****@hotmailxdotx.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... Additionally , as a server ( listen socket ) you can have 10 accepted connections in XP ( look at http://support.microsoft.com/default...b;en-us;314882 ) Arkady
"William Stacey [MVP]" <st*****@mvps.org> wrote in message news:eN**************@TK2MSFTNGP10.phx.gbl... Each socket must be unique by 4 values: IP Local, Port Local IP Remote, Port Remote
When the listener accepts a new socket, it fills (among other things) that socket object with those four values. That means no other socket can use those same values, at least one must be different. So the same client can not connect to the same server and port using the same local IP and port. Clients normally get dynamic ports so that allows a client to connect to the same server/port more then once. On the listening side, when you try to listen to the same IP and port more then once, you get an error unless you allow duplicates which is another can of worms. HTH
-- William Stacey [MVP]
"0to60" <ho****************@yahoo.com> wrote in message news:OZ**************@TK2MSFTNGP09.phx.gbl... I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code:
Socket newSocket = listeningSocket.Accept();
returns a socket. I can communicate on newSocket, and listeningSocket goes back to listen mode. Is newSocket using the port that I bound listeningSocket to? If 5 clients connect to listeningSocket, and you check the remote endpoint on each of them, they will all point to listeningSocket's IP address and the same port. The 5 resulting newSockets local endpoint properties all show the same port that listeningSocket is bound to. Can many sockets all use the same port?
If this is the case, how come when I try to manually bind a some other socket to the port that listeningSocket is listening on, I get a "port in use" error?
So what happens behind the scenes? Does the newSocket use the same port that listeningSocket is bound to? Or does it newSocket get "assigned" a free port by the WSA code wrapped by the Socket class? When I check newSocket's local endpoint property, it says the same port that listeningSocket is bound to. How can multiple sockets be using the same port?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim Kipp |
last post by:
Hi
I am writing a simple server to monitor ports. The problem is I don't know
how to make it listen on multiple ports. It creates the first socket,
listens, than accepts and of course the accept...
|
by: Shaniqua Jones |
last post by:
I've designed a C# application consisting of two EXEs: a client and
server. The server runs on my Win2000 Server box, and the client runs on my
customers' machines -- typically XP. The client app...
|
by: Xarky |
last post by:
Hi,
I am writing a small web server, to listen on web browser
port(8080), if I'm not wrong. Basically for parsing some tags found
in html.
Now I am doing as follows
TcpListener mainTcp =...
|
by: ZorpiedoMan |
last post by:
I'm new to the world of sockets, and this question is not VB specific:
If multiple clients access the same server on the same port, and the server
is set up to do some async communication, does...
|
by: 0to60 |
last post by:
I have a question about socket programming in general.
Exactly what happens behind the scenes when I one socket connects to a
different socket in listen mode? Using the dotnet framework, I...
| |
by: Mark |
last post by:
I am working on a Windows service application that will listen on multiple IPs and ports e.g. port 25, 110 etc. As far as I could see the EndPoint only contains one IP and a port. How is it possible...
|
by: tshad |
last post by:
I have been trying to run IIS and Apache Tomcat on the same Server using the
same Port (80 for http and 443 for https). I am trying to do this by using
multiple IP address on the same Nic card. ...
|
by: jcprince |
last post by:
Hi
Not sure I can do what I'm trying to do without using a 3rd party
component like Dart. I need to build a windows service to create a
socket connection on an IBM mainframe using an IP and port...
|
by: YASIN786 |
last post by:
hi all
here is the question. pls do the needful. am a beginner so don have much of an idea on where to start from. any ideas/links/code will be appreciated:...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |