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 2064
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: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
| |