views:

42

answers:

2

In C++ using Windows32 using windows socket library using UDP is there a way to give a client routing information to another client to establish a connection between clients without having to route through the server

Clarification:

server - waits for computers and gives routing info - a detached server client - sends a ack request and waits for routing info - a normal user computer

but ok so its not posible to give routing info to clients to interconnect clients without requiring the data to be forwarded through the server?

+1  A: 

Short answer: no.

Long answer: No matter what information you include in your UDP packet, at the transport layer it's just another IP packet, and your NIC will slap the appropriate headers on it and send it on its way. Unless the hosts are directly connected to each other, the network topology will dictate how many hops (routers/switches) it has to make to get there.

Addendum:

I'm not sure what you mean by server (I read it as "router" initially, but you could just as easily have been talking about a Domain Name Server (DNS)). If you are trying to avoid DNS lookup, you can easily do this by providing an IP address directly (assuming you know it). However, DNS lookup is a one-time process--once the IP address is known, the DNS host is not involved in routing your UDP packets in any way.

Drew Hall
um ok yes but i dont want to use the server as a router im asking to use it to connect clients, not use it as a router
erai
@erai: I'm still very confused by your terminology. If the clients are not directly attached to each other (e.g. with a single, A->B ethernet cable or an ad hoc WiFi connection), they'll have to go through at least one router (switch/hub/etc.) to connect to each other. I don't see how you plan to avoid that.
Drew Hall
A: 

Short answer: no

Long answer: yes --- but you have to use IPPROTO_IP, not IPPROTO_UDP. Use IP_OPTIONS option in setsockopt() to set source routing.

J-16 SDiZ
thanks ill try that
erai