If you were writing a basic python TCP server and client would you need to add the SYN, SYN ACK and ACK responses yourself or is it taken care of by the socket module?
If you need to write it yourself would it be as simple as something like this?
Client:
#set up clientSocket
data = "SYN"
clientSocket.send(data.encode('utf-8'))
if((clientSocket.recv(1024)).decode('utf-8') == "SYN ACK") {
data = "ACK"
clientSocket.send(data.encode('utf-8'))
}
and the Server responding in a similar way with checking if recv is SYN and then send SYN ACK. If not what is the correct way of implementing it? Haven't ran the above code, not bothered about the syntax being 100% correct just curious about the logic behind it
The SYN and ACK are handled by the operating system, with no direct intervention by the user. The user program is not required, nor is it able, to send the initial SYN, SYN-ACK, ACK handshake packets.
The initial SYN is sent on behalf of the client as a consequence of socket.socket.connect().
The initial SYN-ACK is sent on behalf of the server as a consequence of socket.socket.listen().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With