🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

storing IP addresses using the recvfrom() command

Started by
0 comments, last by kalldrex 23 years, 3 months ago
how would i use the recvfrom() command and store IP of users? I''m using UDP and i''m making an MMORPG so I need it to be able to hold a lot of user''s ip addresses.
ALL YOUR BASE ARE BELONG TO US!!!!
Advertisement

Not exactly sure what your question is, but you can use
recvfrom() like this:

struct sockaddr_in from;
int fromlen = sizeof(from);
int bytes_read = recvfrom( sockRaw, some_buffer, 1024, 0, (struct sockaddr*) &from, &fromlen);

If the call is successful, you can grab the IP address of
the sender like this:

DWORD dwIP = *((DWORD*) (&from.sin_addr));

At this point you can store the dwIP in some dynamic DWORD array. CDWordArray if using MFC, or vector if using STL, etc..

// CHRIS
// CHRIS [win32mfc]

This topic is closed to new replies.

Advertisement