destination port changes every time
I wrote a client/server programs, the server listen on port 5000 and of course the client connected on that port , I check the communication via the sniffex.c program from pcap (adapting something) , I noticed that destination port ( used by the client) is not always the same and completely different from the source port.
Here is an output example:
Device: lo Filter _expression_: ip
Packet number 1:
Protocol: TCP ---->The client send a request
Src port: 49611 ---->The port is randomly choosed by the client ??
Dst port: 5000
Packet number 2:
Protocol: TCP -----------> The answer from the server
Src port: 5000
Dst port: 49611
When I stopped the client and ran it again I got another Src port from the client
The question is : why the port opened by the client is not the same, and takes one randomly ??
thanks for help