On 28-Mar-99 Per Kristian Hove wrote:
> On Sat, 27 Mar 1999, Chris Costello wrote:
> > How is this a bug? It behaves how it should, doesn't it?
> If it does, I'm sorry I've taken up your time on something that isn't a
> bug. I'm not at all a networking guru, it just seemed strange to me to get
> a connection when nothing should be listening to that port.
> But when setting net.inet.tcp.log_in_vin = 1 and try to connect to port
> 3434, I see in my logs
> Connection attempt to TCP 127.0.0.1:3434 from 127.0.0.1:3460
> and when I then try to connect to port 3461 (the "outgoing" port number
> increases by 1 for every connection attempt), that succeeds. So what
> seemed random, it's not random at all.
> I thought you had to explicitly listen() [and then accept()] in order to
> accept connections. But connect()ing on a socket makes it accept incoming
> connections? (And yes, I'm no programmer either).
> This is how I thought it worked:
> When I connect to the port, a port is allocated locally in the local end
> of the connection. Then a SYN is sent to the remote end, and if I get a
> (SYN | ACK) in return, I will get connected to the destination end. If I
> should get just a (SYN | ~ACK), I shouldn't get connected to the remote
> end. I only send a SYN (to myself, by accident, cause the port
> number is the same in both ends of the connection), and since I'm sending
> it to myself, I also think that I'm receiving it. But since it's just a
> SYN, and not a (SYN | ACK), I shouldn't accept that it's a valid response
> to my original SYN. It seems like FreeBSD reads the SYN as 'okay, let him
> have a connection'.
At the risk of adding to the noise level...
As far as the TCP protocol is defined the "three was handshake" for connection
establishment is symmetric. listen() is really only a special case of connect()
that does not time out (and allocates a new socket etc.). Doing reasonably
simultaneous connects on both ends is supposed to work and there may even
be programs that depend on it.
This is like PPP, where the protocol is symmetric and the being a "client" or
"server" just depends on a willingness to time out.
Jonathan Hanna <firstname.lastname@example.org>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message