I'm having an issue with a tcp handshake that I can't find the answer to anywhere else.

I have a program running on my local device that posts data to port 50000. In a terminal on the same machine, I use netcat to connect to the port. However, while using tcpdump and wireshark, I can see that the SYN packets are sent but the SYN/ACK packets are never sent in response. My iptables have no rules for connections, and the default policy for all chains is to accept the connection. This happens every time I try to connect, and so far I can't see why the server is not responding to the SYN packets.

  • What is listening on port 50000? – Michael Hampton Jan 15 at 20:34
  • I have a C program that creates a socket and listens to port 50000. nc localhost 50000 is used to connect to the port. This command sends the SYN packets, and since it doesn't get a response it retransmits them. – Austin Jan 15 at 20:35
  • Your program needs to accept() the connection. It sounds like it is not doing so for some reason. You can get help debugging your program on our sister site, Stack Overflow. – Michael Hampton Jan 15 at 20:36
  • I can see that the SYN packets are sent but the SYN/ACK packets are never sent in response - Is the SYN being received? It sounds like you're troubleshooting this from only one side. – joeqwerty Jan 15 at 20:37
  • @MichaelHampton you're right, accept() needs to run. From what I've seen this takes place after the handshake is complete, so it appears I'm not even getting to this point. – Austin Jan 15 at 20:41

I fixed it. To my dismay, it actually was a code issue. We set our listen() backlog size to 0, causing any attempted connection to fail. In the case of TCP this meant retransmitting the packets. Don't know how this worked on one machine and not the other, but now they both work. Thanks for the comments everyone.

  • 1
    Glad to hear something let you solve it! – Anon Jan 18 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.