storing IP addresses using the recvfrom() command
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!!!!
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
Popular Topics
Advertisement