UDP help

Started by
11 comments, last by Robinhood 19 years, 10 months ago
When you call recvfrom, the IP address in the struct sockaddr_in will be the address of the client.

That''s all the server needs to know. The server does not need to know its own IP address - and with good reason - NAT and/or multihomed hosts may make it impossible in the general case for a server to have exactly one IP address.

You should receive the real IP / port number of the clients from recvfrom, if it''s a "Virtual" IP whatever that is (probably a reserved IP?), then the clients'' IP addresses must have been NAT''d by your firewall.

But in any case, you don''t care what they are, just send the responses back to the same IP / port that the requests came from, and it should be fine.

Mark
Advertisement
Thank you for your help.But my server is in network A and my IP is something like "10.0.0.14",and then the clients outside network A want to send message to the server,then where should clients send their messages("10.0.0.14" obviously is allocated by DHCP)
If you''re behind a router with your own IP addresses, then there''s nothing the outside world can to to choose to contact individual computers on your network directly. All you can really do is set up port forwarding on the router that will map inbound requests on given ports to designated machines.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

This topic is closed to new replies.

Advertisement