I have two C files i.e server.c and client.c. Initially in server side I created the socket and fixed a port on which the server can listen and send . But in client side when I send any message to the server side how should I explicitly assign a client source port on which it can listen. Everytime the kernel assigns a random port no. between 1024 to 65535. But how can I explicitly define the client source port in UDP communication?
This link I found for TCP communication. I want for UDP.
For example: On server side: Server Created Binded Correctly Listening ... Connection Established connection established with IP : 10.0.2.15 and PORT : 40064 Client : Hello
On Client side: Client Created Binded Correctly Client Connected Server : Hello
40064 is randomly assigned by the kernel to the client. But I want to explicitly set that port on client side for UDP. Is there any function or command to do it?