Board index » delphi » Getting the IP address of a client

Getting the IP address of a client

Hi guys.

I am trying to do a program that uses a TServer socket. The program should
listen to a certain port say 1110 and keep adding all the text or whatever
it receives to a TMemo. I achieved this by putting the following line of
code on the OnClientRead event handler of the TServer socket:

Memo1.Lines.Add(Socket.ReceiveText);

This works fine and all the incoming text is added to the memo box 1. Now I
have another memo2 and I want to display the IP address of the remote
computer (the client) into memo2 when some text is received. I tried putting

Memo2.Lines.Add(Socket.RemoteAddress);

but this does not work.

1. How could I get the IP address of the client computer that has connected
to the server?

2. I tried to send back some text to the client through the server by
putting

Socket.SendText('bla bla bla');

but this did not work either. Please HELLLLPPPP me. Thanks in advance for
your assistance.

 

Re:Getting the IP address of a client


1.To Get The Client IP Address:

ShowMessage(Thread.Connection.PeerAddress);

P.S: Thread is the variable that is On ONEXECUTE of the Server...

*****************************************************************

2. To Send some text to Client from server:

Thread.Connection.WriteLn('bla bla bla');

P.S: Thread is the variable that is On ONEXECUTE of the Server...

****************************************************************

George.

Quote
h.abdullah wrote in message ...
>Hi guys.

>I am trying to do a program that uses a TServer socket. The program should
>listen to a certain port say 1110 and keep adding all the text or whatever
>it receives to a TMemo. I achieved this by putting the following line of
>code on the OnClientRead event handler of the TServer socket:

>Memo1.Lines.Add(Socket.ReceiveText);

>This works fine and all the incoming text is added to the memo box 1. Now I
>have another memo2 and I want to display the IP address of the remote
>computer (the client) into memo2 when some text is received. I tried
putting

>Memo2.Lines.Add(Socket.RemoteAddress);

>but this does not work.

>1. How could I get the IP address of the client computer that has connected
>to the server?

>2. I tried to send back some text to the client through the server by
>putting

>Socket.SendText('bla bla bla');

>but this did not work either. Please HELLLLPPPP me. Thanks in advance for
>your assistance.

Other Threads