|
1. 이런식으로 보낼 수 있습니다.
뭐 스트링말고 버퍼는 함수만 바꾸면 됩니다.
try
IdTCPClientCDI.IOHandler.Write(asTemp);
except
on E : EIdException do
begin
try
if EIdSocketError(E).LastError = 10054 then
Disconnect
else if E.Message = 'Connection Closed Gracefully.' then
Disconnect;
except
end;
end;
end;
2. 읽을땐
if Connected = True then
begin
try
//////////
// Receive
asLine := IdTCPClientCDI.IOHandler.ReadString(IdTCPClientCDI.IOHandler.InputBuffer.Size);
//if IdTCPClientCDI.IOHandler.InputBufferIsEmpty then
// IdTCPClientCDI.IOHandler.CheckForDataOnSource(100);
//if IdTCPClientCDI.IOHandler.InputBufferIsEmpty = False then
// asLine := IdTCPClientCDI.IOHandler.InputBuffer.Extract(IdTCPClientCDI.IOHandler.InputBuffer.Size);
// asLine := IdTCPClientCDI.IOHandler.InputBuffer.ExtractToString;
//IdTCPClientCDI.IOHandler.CheckForDisconnect(True);
except
on E : EIdException do
begin
try
if EIdSocketError(E).LastError = 10054 then
Disconnect
else if E.Message = 'Connection Closed Gracefully.' then
Disconnect
else
asLine := '';
except
end;
end;
end;
|