Archived

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

3DNeophyte

recvfrom( ) returns NULL pointers

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