I am trying to communicate between two PCs on a network using a
TServerSocket and a TClientSocket. I did this a few years back at a
different company without any problems, but for some reason the IP Address
of the server socket connection is 127.0.0.1 and not the IP Address of the
PC the server socket is created on. In other words, the client socket will
only connect to the server if it uses an IP address of 127.0.01, and it is
on the same PC as the server socket. I suspect this has something to do with
how the network is setup. Does anyone know what the problem might be?
> for some reason the IP Address of the server socket connection
> is 127.0.0.1 and not the IP Address of the PC the server socket
> is created on.
The only way that can happen is if you are explicitally telling
TServerSocket to bind to that specific IP address when it opens its
listening port. To bind a TServerSocket to a specific IP, you have to
assign the (protected) Address property. Otherwise, it binds to 0.0.0.0
instead, which tells it to listen on all available IPs.
> In other words, the client socket will only connect to the server if
> it uses an IP address of 127.0.01, and it is on the same PC as
> the server socket.
What happens exactly when you try other IPs?
Gambit
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
> When I use the IP Address of the PC
Use it where exactly? Please be more specific.
> I get "Asynchronous sockey error 10060".
That is WSAETIMEDOUT.
> If the server is not open, and I try to connect I get the same error.
You should be getting a different error if the server is not running at all.
Gambit
For the server socket the code does this:
ServerSocket := TServerSocket.Create(nil);
ServerSocket.Port := 1025;
ServerSocket.ServerType := stNonBlocking;
ServerSocket.Open;
For the client socket the code does this:
Self.ClientSocket := TClientSocket.Create(nil);
Self.ClientSocket.Address := '192.162.25.83';
Self.ClientSocket.Port := 1025;
Self.ClientSocket.OnConnect := Self.OnConnect;
Self.ClientSocket.OnRead := Self.OnRead;
Self.ClientSocket.Open;
If I change to:
Self.ClientSocket := TClientSocket.Create(nil);
Self.ClientSocket.Address := '127.0.0.1';
Self.ClientSocket.Port := 1025;
Self.ClientSocket.OnConnect := Self.OnConnect;
Self.ClientSocket.OnRead := Self.OnRead;
Self.ClientSocket.Open;
The connect is made and I can send messages back and forth. However, using
127.0.0.1 only works if the server and client sockets are on the same PC, so
this will not work.
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47583fbe$1...@newsgroups.borland.com...
> For the server socket the code does this:
Then it should be binding to all available IPs on the machine (you can use
netstat or other tool to verify that). You should not be having any trouble
accessing the server using any of those IPs on the client side, provided the
client machine has network access to those IPs in the first place (use ping
to find out).
Gambit
Could be a firewall issue. In the company I work for all office PCs now
use XP and have a firewall installed that blocks all ports for incoming
connection request. This means that it is impossible to run a TCP/IP
server on one of those PCs, if you try only a client running on the
same machine can see the server. I had to move all my services to a
dedicated server machine to get my programs working again in the new
environment...
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
If you do "netstat -a" it will show you what ports are listened on and
connected etc, if you dont see your port in there, its not listening.
If it is listening but you cant connect then its most likely a firewall
issue.
--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings