I started working recently in IT field and as first assignment they want me to communicate with a remote board with a simple Socket using Java. Today I completed all the job but I noticed that my messages wasn't correctly received... So I started digging and start using wireshark for a better understanding of "What is going on?". I know that before sending data the client and server do the 3-way handshake, then the client send its data and when its done it close the connection and say by to the server. Now thats my question: Im sending a packet to the remote board using Packet Sender (perfect for debug and test) and that's what I see:
First 3 message are the handshake
1. client SYN server
2. server SYN, ACK client
3. client ACK server
then I got this messages
4. client PSH, ACK server
5. server ACK client
6. client FIN, ACK server
7. server ACK client
8. server FIN, ACK client
9. client ACK server
The PSH is the phase where I sent the byte to the server socket, then the server reply so I close (FIN) the connection and then the server does the same. These order is super important to be respected in order to have a right communication? This is the result of my packet sent using my program in JAVA:
Handshake
1. client SYN server
2. server SYN, ACK client
3. client ACK server
then I got this messages
4. client PSH, ACK server
5. client FIN, ACK server
6. server ACK client
7. server ACK client
8. server FIN, ACK client
9. client ACK server
What do you think? How can I fix this problem? It's really annoying because the server didnt do nothing at all. Should I try to let the socket opened for a few milliseconds? Does the TCP protocol work always like described above in the Packet Sender example or can be mixed with more request as happen in my program? Thank you all