Home > Back-end >  Help: about TIdTCPServer receive data
Help: about TIdTCPServer receive data

Time:10-13

My server TIdTCPServer ReadLn () to receive data from the end of the service, these data may have 0 0 d a, when encounter this error, how to solve? Seldom used Delphi, ask everybody to help

CodePudding user response:

Then don't readln, od oa is a newline, you still read binary stream, Execute event AThread. Connection. ReadBuffer

CodePudding user response:

Received by ReadBuffer
Send with the WriteBuffer

CodePudding user response:

The top two masters, master followed in the footsteps of
Indy
AThread. Connection. ReadBuffer

CodePudding user response:

refer to the second floor kaikai_kk response:
receive by ReadBuffer
Send with the WriteBuffer

The end of the service is not my control, how to send there, I don't know,
Is such a thing actually, others through a web post a file, I accept the end, then there may be a carriage return

CodePudding user response:

ReadLn () the first parameter is the end of the read data symbols, default is # 10 (wrap), change to a different look, no can't do

CodePudding user response:

reference 4 floor hanhanwang response:
reference kaikai_kk reply 2 floor:

Received by ReadBuffer
Send with the WriteBuffer

The end of the service is not my control, how to send there, I don't know,
Is such a thing actually, others through a web post a file, I accept the end, then there may be a carriage return.

What other people how is he
Just receive ReadBuffer with yourself!

CodePudding user response:

refer to 6th floor mhhaifeng response:
reference 4 floor hanhanwang response:
Refer to the second floor kaikai_kk response:

Received by ReadBuffer
Send with the WriteBuffer

The end of the service is not my control, how to send there, I don't know,
Is such a thing actually, others through a web post a file, I accept the end, then there may be a carriage return.

What other people how is he
Just receive ReadBuffer with yourself!

I am using is INDY10, how didn't see the ReadBuffer? Seems to be slightly different with the INDY9, Execute the parameters of the event is TIdContext, not the AThread said above, how can I call this function?

CodePudding user response:

There are two methods can be read in
I speak a I use here,
RxBuf: TIdBytes;
AContext. Connection. IOHandler. ReadBytes (RxBuf, SizeOf (Paquete));
Idglobal. BytesToRaw (RxBuf Paquete, SizeOf (Paquete));

What I read in Paquete bag, of course, Paquete attribute to define yourself,

Send is
RxBuf:=Idglobal RawToBytes (Paquete, SizeOf (Paquete));
AContext. Connection. The IOHandler. Write (RxBuf);
But you don't need to send, right,



CodePudding user response:

The byte, conversion, it's so trouble
  • Related