Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Indy + TIdTCPClient + sending/receiving non-terminated text

Status
Not open for further replies.

ArbiterX

Programmer
Apr 24, 2007
1
SE
Hi,

I would like to know a convenient method to send a text string in unaltered form to a server(this is not a delphi server), and then receiving the servers reply which is in the same format, a non terminated text string. The textstring might have carriage return and newline in the middle of the text, so I want to take care of the entire message.

Here is a code-snapshot from the client:

Client.Connect;
try
Client.Socket.Write(testString);
// Here, I am supposed to receive the reply from the server.
finally
Client.Disconnect;
end;
end;


I am sending the string correctly? And how can I receive the textstring from the server afterwards? I have tried the read methods from socket class, but they lock up, as in they seem to be polling there forever.

Thanks in advance, I appreciate your help.
 
Try using the ReadStream method for the indy socket. This should continue to read until the socket is closed. There needs to be some sort of protocol for you to follow, either the server indicates the size of it's response before sending it, it's response will be terminated in some way, or it's response will be a fixed length. Otherwise there's no way to know if the server responded correctly, or it timed out during sending it's response.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top