recvfrom( ) returns NULL pointers

Started by
2 comments, last by 3DNeophyte 20 years, 1 month ago
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?
Advertisement
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...
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.

Yeah, man pages. Should''ve referred to those instead of the WinSock2 API docs. Thanks

This topic is closed to new replies.

Advertisement