Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : A polite request for Advice on using Sockets
| Subject: | A polite request for Advice on using Sockets |
| Posted by: | "DC" (e..@egg.ns.com) |
| Date: | Tue, 10 Apr 2007 07:38:30 |
Hi,
My experience with sockets is minimal so please bear with me.
I have to communicate with a 3rd party app over TCP
The API docuumentation tells me that..........
I should establish a connection.
Send a request string
and I will receive the response on the same connection.
So it seems that a TClientSocket in ctBlocking mode is up to the job.
Could someone please tell me if this is correct.
Also, I may need to also use this in a service app - would the same code be
OK there.
If I am wrong - some exapmples would be greatly appreciated.
with ClientSocket do
begin
try
ClientType := ctBlocking;
Address := edtIP.Text;
Port := sePort.Value;
Host := edtIP.Text;
Open;
Socket.SendText( Req );
//Close;
Delay( 1000 );
Resp := '';
repeat
st := TWinSocketStream.Create( cs.Socket, 1000 );
if ST.WaitForData( 1000 ) then
Resp := cs.Socket.ReceiveText;
until s <> '' or Timout
close;
except
on e:exception do
s := 'ERROR - Not on socket: ' + e.Message + #13 + 'Address : '
+ Address;
end;
end;