🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages Started by sez Tue, 06 Jun 2006 02:33
Is the server reachable?
#2282
Author: sez
Date: Tue, 06 Jun 2006 02:33
28 lines
1603 bytes
Hello,

I'm developing p2p chess program including indy tcp server and client.

My computer uses router. I changed some options from "virtual server" and 
added port of the program. I activate server, my friend can connect me as a 
client. Everything seems ok.

However, the server side must detect if the server is reachable or not.

For example, if I wouldn't add the port, my friend would get connection 
error.
In order to prevent this, when I activate the server, the program must check 
if the server is reachable.

e.g
if (is_reachable())
ShowMessage("Ok, your peer can connect to you.");
else
ShowMessage("You are using router and have to add a port to virtual 
server.");

is_reachable(){
// What can I write here?
}

Thanks,
Sezgin 
Re: Is the server reachable?
#2283
Author: Remy Lebeau (TeamB)
Date: Tue, 06 Jun 2006 02:41
31 lines
2597 bytes
"sez" <www@sezginserin.com> wrote in message
news:4484e97d@newsgroups.borland.com...

> if I wouldn't add the port, my friend would get connection error.
> In order to prevent this, when I activate the server, the program
> must check if the server is reachable.

It won't be able to.  Only the client will be able to detect that when it
tries to connect to the server.  All the server can do is report whether it
was able to bind to the local IP/port that the router is configured to
forward traffic to.  The server won't even know that a router is even
present on the network, since the router acts as the client.  So as far as
the server ever knows, if it binds successfully, then it is always reachable
on the network.  The server will have no clue how clients reach it from
outside the network.

To get around this, you need to swap the roles of the sockets.  In other
words, if Player A opens a server socket that Player B tries to connect to,
and the connection fails for any reason, then Player B can open its own
server socket that Player A then tries to connect to.  Chances are, the
connection will succeed in one direction or the other.  That is how most
modern p2p applications work nowadays.  Typically, the only time it wouldn't
work at all is if both parties are behind their own individual routers and
neither one is properly configured for port forwarding.  The only way to
make the connection work in that scenerio is to have both parties connect to
an external server that acts as a proxy who forwards data back and forward
between both connections.


Gambit
Re: Is the server reachable?
#2284
Author: sez
Date: Tue, 06 Jun 2006 05:18
7 lines
1088 bytes
> It won't be able to.
Great!

> To get around this, you need to swap the roles of the sockets.
I'll try it.

Thank you for the answer, Remy. 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads