Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Recvfrom and multiple clients from the same host


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 KnolanCross   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 28 November 2012 - 06:18 PM

Hi there, I am creating a small side project, it is yet another UDP with confirmation solution.
I am using C on linux, trying to remain as close to POSIX as possible, so I won't have a hard time porting it to windows.

Right now I am facing the following problems:

1) Client A and Client B are behind a router, so I receive their messages (using recvfrom) and their addr struct show the same IP. Is there any API provided information that I can use I should I implement some kind of handshake where I can give each of them a random number to identify them?

2) Whenever I receive the first message from some IP, the address returned is FFFFFFFF. Any ideas?

Thanks in advance.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).


Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 16378

Like
0Likes
Like

Posted 28 November 2012 - 07:50 PM

For the first question, this is a natural consequence of how NAT works. If you want to uniquely identify endpoints behind NAT, you will need to assign them some kind of identifier yourself besides just address.

The second question just sounds like a bug in the way you use the APIs; if you could post some (minimal) code that reproduces the problem that'd be helpful.

#3 hplus0603   Moderators   -  Reputation: 5692

Like
1Likes
Like

Posted 28 November 2012 - 08:31 PM

While client A and client B will have the same IP address, they will have different source ports.
Think about it: If there was no way to tell them apart, how could the router know which return packet to send to which client?
Thus, you can simply identify the clients with their remote IP:port tuple, just like with any other clients.

enum Bool { True, False, FileNotFound };

#4 KnolanCross   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 28 November 2012 - 08:54 PM

While client A and client B will have the same IP address, they will have different source ports.
Think about it: If there was no way to tell them apart, how could the router know which return packet to send to which client?
Thus, you can simply identify the clients with their remote IP:port tuple, just like with any other clients.


Lol, that was really obvious. I feel stupid now lol.
Thanks a lot hplus.

EDIT:
2nd problem solved.
In case anyone find this with the same problem I had, you need to start the addrlen with sizeof(struct <your address type);

Edited by KnolanCross, 29 November 2012 - 06:58 AM.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS