[BusyBox] tftp: bind with no sin_family
Shaun Jackman
sjackman at gmail.com
Thu May 19 05:32:57 UTC 2005
These two lines from tftp.c have me a little confused:
memset(&sa, 0, len);
bind(socketfd, (struct sockaddr *)&sa, len);
With no sin_family value set, does this call mean anything to the
kernel? The call succeeds under Linux at least, but I have no idea
what effect the call has.
Could these lines be removed with no ill effect? Do they perhaps have
the same semantics as the following:
memset(&sa, 0, len);
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = INADDR_ANY;
bind(socketfd, (struct sockaddr *)&sa, len);
If so, is the kernel inferring the sin_family type from the domain of
the socket file descriptor?
This is mostly for my own curiosity. I really expected the bind call
to fail and was rather surprised when I saw that it didn't. I'd
appreciate someone putting my mind to rest.
Cheers,
Shaun
More information about the busybox
mailing list