socket bound?
Ron Stanonik
stanonik at nprdc.navy.mil
Fri Jun 15 23:50:25 AEST 1990
"Seriously, what are you trying to do?"
The problem is that I'm using a library routine (clntudp_bufcreate
in sun's yp/nis library) which returns a socket. The routine apparently
attempts to bind the socket to a priviledged (< 1024) port. Because
of this undocumented "feature", if the user is root, then the socket
returned is already bound and any attempt by the user to bind it will
fail.
Ah, you exclaim, check errno and if it indicates "already bound",
then ignore the error.
The errno, EINVAL, can mean "already bound" OR it can mean "namelen is wrong",
in sunos4.X. True, I can probably assume that namelen is okay, since I code
flawlessly. :-) If sun hadn't overloaded EINVAL, then checking errno would
unquestionably be the solution.
My question about unbinding a socket was just idle curiousity spurred
by trying to deal with this "is it bound or is it not" problem.
Thanks,
Ron
stanonik at nprdc.navy.mil
More information about the Comp.unix.wizards
mailing list