My UDP/IP Dilemma

Started by
2 comments, last by Null and Void 22 years, 12 months ago
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
Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
Advertisement
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
-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
Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
I think I got it working now, by doing this (basicly):
sockaddr_in a = *((sockaddr_in *) &b);



Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/

This topic is closed to new replies.

Advertisement