Advertisement

HawkNL: "The namelen argument is incorrect"

Started by July 24, 2005 07:39 PM
4 comments, last by SiCrane 19 years, 6 months ago
I'm trying to work on a multiplayer game server in HawkNL, and whenever I try to write my packets to the client, I get a system error: "The namelen argument is incomplete". Cursory googles appear to reveal nothing (other than that this error is also in WinSock), so what exactly does this error mean and what should I do to resolve it? I get this regardless of client (both netcat and my "official" client do this) and computer (either connecting from across my LAN or on the same machine). Netcat fills up with "NLNLNLNLNLNLNL..." over and over and my client receives "NL" then gets a "The NL_RELIABLE_PACKET stream is out of sync" error, FYI. Changing the mode from NL_RELIABLE_PACKET to NL_RELIABLE (on both client and server) makes the error on the client disappear (as well as the "NLNLNLNL" on netcat), although the namelen error still exists on the server and so nothing gets "sent" to the client. My rough assumption is that the server needs to somehow know the name of the remote socket in order to communicate with it and this is not done automatically.
It's kind of hard to give any advice if you don't even mention what function is giving you this error, or how you are calling it.
Advertisement
Quote:
Original post by SiCrane
It's kind of hard to give any advice if you don't even mention what function is giving you this error, or how you are calling it.


Woops. I'm using:

nlWrite(player->getSocket(), thisPacket->serialize(), thisPacket->getSize())


player->getSocket() returns the NLsocket that the player originally connected with (that was retrieved from the listener).

thisPacket->serialize() returns a serialized version of the packet (as char*) that is intended to be tossed over the network. I have a wager this code is buggy, but it's not even getting sent out so I can't check to see if it's making proper packets yet.

thisPacket->getsize() just returns the size in bytes of the serialized packet. For the one I'm testing, it should send 14 bytes. (two floats, 3 unsigned short ints).

From the HawkNL documentation, I'm told that nlWrite returns the number of bytes written or NL_INVALID (-1) on failure. I detect the -1 and then go to use the HawkNL functions for printing out the system error.
Check the return value on thisPacket->serialize(). One possible cause of a EFAULT is that the pointer specified in call to send() is a non-valid address such as that reserved for kernal addresses or IIRC the null pointer.
Quote:
Original post by SiCrane
Check the return value on thisPacket->serialize(). One possible cause of a EFAULT is that the pointer specified in call to send() is a non-valid address such as that reserved for kernal addresses or IIRC the null pointer.


That may be it. I just now notice that trying to printf the char* I get back from there causes a segmentation fault, unless I print it out in hex which returns 1000e (and is much too short to be 14 bytes). Just sending a dummy string like "moo" appears to go through fine without triggering the error.

I'll look over my serialize function some more.
Edit: Ahah! memcpy(buf, &myStruct, sizeof(myStruct)) NOT memcpy(&buf, &myStruct, sizeof(myStruct)). Doyyyyyyy. Stupid pointers.

[Edited by - Ravuya on July 24, 2005 8:06:48 PM]
If this a windows box, the address 100e lies in the protected lower memory area, which will register a EFAULT.

This topic is closed to new replies.

Advertisement