A
anketm
I am writing a simple client using UDP sockets.
I am wondering if there is any way to determine what local port a
socket was bound to when bind() is not explicitly called.
This is what my program looks like:
sock = socket(PF_INET, SOCK_DGRAM, 0);
sendto(sock, message, strlen(message) + 1, 0, (struct sockaddr *)
&server, sizeof(server));
Note that bind() was not called, and the socket was arbitrarily(?)
bound to a local port by the kernel. How do I determine what port it
was bound to?
Thanks.
Anket Mathur
I am wondering if there is any way to determine what local port a
socket was bound to when bind() is not explicitly called.
This is what my program looks like:
sock = socket(PF_INET, SOCK_DGRAM, 0);
sendto(sock, message, strlen(message) + 1, 0, (struct sockaddr *)
&server, sizeof(server));
Note that bind() was not called, and the socket was arbitrarily(?)
bound to a local port by the kernel. How do I determine what port it
was bound to?
Thanks.
Anket Mathur