ANET_AddrToString gives garbage?

Everything todo with programming goes HERE.
Post Reply
User avatar
Lucifer
Project Developer
Posts: 8683
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

ANET_AddrToString gives garbage?

Post by Lucifer »

I snagged ANET_AddrToString from nSocket.cpp (I think) for my robot, and noticed the first time I use it I get garbage. This is a basic setup, using recvfrom() to read from the socket. Did I not do something right setting up the socket, or did I uncover an odd bug in this function?

Code: Select all

Received login from 232.202.229.183:52151
Received login from 127.0.0.1:10000
The second line is correct, I only get garbage on the first line.
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Lucifer
Project Developer
Posts: 8683
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Post by Lucifer »

Wow, it literally is only the first datagram sent after the robot is started. The second one sent from the client, in the same process with no additional socket stuff gives the correct address string.
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Z-Man
God & Project Admin
Posts: 11624
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

I've seen an error like this somewhere else, it was caused by an uninitialized variable, specifically the fromlen parameter of the recvfrom function, the int it points to needs to be set to the size of your sockaddr type.
User avatar
Lucifer
Project Developer
Posts: 8683
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Post by Lucifer »

Haha, that worked. Thanks. :)

I guess this is in the wrong place now, heh.
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
Post Reply