Without attempting to bind it
+2
A:
This should do the trick...
int getsockname(int socket, struct sockaddr *restrict address,
socklen_t *restrict address_len);
ProZach
2009-07-22 17:53:04
...interpreting the question as "I think I bound a UDP socket, but I'm not sure if I did", then yes. (It's not the first interpretation I came to, but unless OP speaks up otherwise, it seems valid to me.)
ephemient
2009-07-22 17:59:50
+2
A:
What's wrong with attempting to bind the port? If it works, you can unbind the port right away. If it fails, you can check the error code to see if it's bound. Either that, or just try to connect to the port.
Michael Mior
2009-07-22 17:53:13