recvfrom() problem
recvfrom() problem
- Subject: recvfrom() problem
- From: Nils Angquist <email@hidden>
- Date: Tue, 29 Oct 2002 08:35:03 -0800
I have an application using UDP under BSD, in which I see some strange
behaviors.
When calling recvfrom(), my "struct sockaddr *from" (see man page)
doesn't always get filled out. It seems to be completely random if it
works or not between different test-runs. On several occasions I've had
it working on one test-run, then fail on the next one, only quitting
and restarting the app in between (same build).
recvfrom() never returns an error (-1 and setting the errno variable),
it always returns the number of bytes received, and the transfered data
is correct. The only thing not working is that "struct sockaddr *from"
doesn't get filled out.
I use inet_ntoa(from.sin_addr) to get the ip of the machine that sent
the message, and it comes out as 0.0.0.0.
The strange thing is that it sometimes work. I am testing over a
cross-over cable + two machines, with the ip's 192.168.0.2 and
192.168.0.3. These are the ip's I get from inet_ntoa() when it works.
Running in a debugger, the value from the ip inside of the struct
sockaddr doesn't even get touched when recvfrom() is called.
Can anyone explain this behavior?
Thanks a lot for any help!
- Nils
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.