Re: Socket question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Alun Jones" <alun@xxxxxxxxxxxxx> wrote in message news:OUzDcY6WJHA.4384@xxxxxxxxxxxxxxxxxxxxxxx
"m" <m@xxx> wrote in message news:#CAFxcNWJHA.1576@xxxxxxxxxxxxxxxxxxxxxxx
False!

<snip>
because no 2 sockets share same
source IP/source port
</snip>

This is only true for outbound connections. A server app has many sockets with the same local IP and port.

This isn't even true for outbound connections.

The only guarantee of uniqueness necessary (or provided) is that the combination of { protocol, source address, source port, destination address, destination port } is unique.

What may have confused you is that an unconnected socket has destination address and port set to 0, but again, those sockets only need to be unique if they are used as TCP listeners or unicast UDP receivers.
That's right. However, you need to explicitly bind sockets to specific port for that (so that more than one outbound socket use same src port) and use SO_REUSEADDR option. Without such explicit steps, same src port won't be used by multiple sockets.

Boris

.



Relevant Pages

  • Re: network programming: how does s.accept() work?
    ... The program you contact at Google is a server. ... so, the server will usually assign a new port, say 56399, specifically ... connections to a server remain on the same port, ... sockets is what identifies them. ...
    (comp.lang.python)
  • Re: "C - like: THIS" pointer to a task type inside a task function
    ... clients through N sockets, using the SAME PORT. ... Each connection has a socket. ... reader queueing them and delivering each request per time to the ... Selectreturns list of sockets available to read without blocking. ...
    (comp.lang.ada)
  • Re: Listening and Establish TCP connections on/from the same IP end po
    ... and accept client connections as well as be able to establish connections to ... The application needs to listen on a specific port because that's where the ... But it does not allow both sockets to actually _use_ that IP/port at the same time, nor would there be any reliable way to let that happen. ... Client ports are pretty much _never_ assigned according to protocol, and firewalls don't block inbound traffic based on the sender's port at all. ...
    (microsoft.public.dotnet.framework)
  • Re: blocking sockets?
    ... The server handles requests and spawns a child process for every connection. ... If a client sends the text "foo" to the server, the server itself should try to make a connection with another service on port 4321. ... The parent process should still be listening on port 1234 if you have actually spawned a child process to read and write data from the remote client,. ... Non-blocking sockets. ...
    (perl.beginners)
  • Re: Socket switch delay
    ... hadn't realized the bit about the completion port... ... > can come back with partial buffers from a completion io. ... > in the client and server. ... > remember changing in the server was the "non-blocking sockets" together ...
    (microsoft.public.win32.programmer.networks)