Accept () and tcp / ip handshake

I am using the JavaServer class for a server application. Does the accept () method accept tcp / ip in a handshake?

As I see in the tcp / ip dump and the netstat command, clients establish connections with before invoking the accept method and returning the Socket object.

Is this a java problem, or am I not understanding accept () semantics?

+4
source share
3 answers

Typically, on Unix, if you mark a socket with listen (), the operating system starts accepting connections. When you call the accept () function, the operating system simply passes an already open connection. Listen takes a parameter that allows you to specify how many "unaccepted" open connections the OS allows (that is, the size of the queue).

+6
source

The accept method does not take an active part in the handshake. Messages are sent and received on the TCP / IP protocol stack, usually in the kernel space of the OS.

However, the accept() method is involved in the sense that the TCP / IP stack only sends a SYN-ACK message if any process has an accept() call active for the socket associated with the corresponding IP address and port. When the three-way handshake is completed, the call to the accept() method ends.

If no process calls accept() over time, the incoming SYN message will be discarded by the kernel and the remote client will eventually disconnect the connection attempt. (On the other hand, if the IP address / port is not mapped, the kernel will most likely respond with RST, and the remote client will see “connection refused”.)

+1
source

Accept returns only after connecting the client and server (handshake, etc.).

0
source

All Articles