Well, I have my third TCP/IP wrapper class done, and I wanted to make myself a UDP/IP wrapper, and I''ve never done it before. So, I set about making it, and have it working for the most part. There''s only one problem, how do I find out if the person I just received a recvfrom data chunk from is the same person as someone I''ve already recorded? I.e. what peice of sockaddr is unique to a single person''s computer/IP Address/whatever? I realized that sockaddr.sa_family always seems to be two, and sockaddr.sa_data seems to be somewhat random, so I''m kind of lost. Thanks in advance for curing my UDP/IP ignorance .
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://druidgames.cjb.net/
My UDP/IP Dilemma
For UDP cast the sockaddr structure to a sockaddr_in structure. You identify a particular user by his ip:port combo (sin_addr and sin_port).
Be sure to keep both the ip and the port. Some code just keeps the ip and breaks whenever you have multiple users on the same client box or when there''s a NAT around.
-Mike
Be sure to keep both the ip and the port. Some code just keeps the ip and breaks whenever you have multiple users on the same client box or when there''s a NAT around.
-Mike
-Mike
Yeah, I thought that''s what I was suppossed to do, but it says that it cannot cast sockaddr to sockaddr_in. So, I replaced all of the sockaddr''s with sockaddr_in''s, then casted it back to sockaddr in the correct places, and it just crashed...
I''m kind of lost at the moment...
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://druidgames.cjb.net/
I''m kind of lost at the moment...
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://druidgames.cjb.net/
I think I got it working now, by doing this (basicly):
sockaddr_in a = *((sockaddr_in *) &b);
http://druidgames.cjb.net/
sockaddr_in a = *((sockaddr_in *) &b);
http://druidgames.cjb.net/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement