Archived

This topic is now archived and is closed to further replies.

recvfrom( ) returns NULL pointers

This topic is 5019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my UDP server code, I make a call to recvfrom(udp_sock, ibuffer, MAX_MSGSIZE, 0, (sockaddr*)client, clientlen), where ''client'' is a pointer to a sockaddr structure and ''clientlen'' is an int* . This works fine in that I am able to receive messages from the client. However, sending back to the client crashes because recvfrom() returned NULL for the ''client'' and ''clientlen'' pointers. Anyone know why this is happening?

Share this post


Link to post
Share on other sites
Ok, problem solved. ''client'' and ''clientlen'' must be non-NULL when passed into recvfrom(). Go figure... why the docs didn''t mention this, I have not clue. All is well now...

Share this post


Link to post
Share on other sites
taken from the recvfrom manpage:

quote:

If from is not NULL, and the underlying protocol provides the source address, this source address is filled in. The argument fromlen is a value‐result parameter, initialized to the size of the buffer associated with from, and modified on return to indicate the actual size of the address stored there.


Share this post


Link to post
Share on other sites