http://bbs.csdn.net/topics/390473005
The other client sends data such as: 68 00 00 After the reception is complete, the data length is correct (13), but when the receiving result is displayed, only one letter H (68 of the character) is displayed, and the subsequent series is not displayed (00 has no corresponding character, the problem should be here). Excuse me, how can I complete the data I received from the show?
more 0
The user should not send a string. All data can be seen as being saved in memory in bytes. 1 a 2 c.
As for the expression is a struct, number, character this is your agreement to decide.
An array buffer is created first when it is received Buf:array [0..1023] of Byte; Save the data in this buffer. As for what you say, you have to decide how to display it according to your agreement. |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Yjianxi
- Bolo_yang
-
This edition level:
|
#2 Score: 0 replies.: 2013-05-28 15:03:13 Socket.receivebuf () can be read into memory |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#3 Score: 0 replies.: 2013-05-28 16:08:47 Save to buffer can be done. But how do I take out the buffer inside the contents are empty, the program is as follows, please help to see where the wrong Procedure Tmainform. Tcpserver1clientread (Sender:tobject; Socket:tcustomwinsocket); Var Ilength,i:integer; Ireceived:integer; Buff:array of Byte; s:string; Begin S:= "; Ilength:= socket.receivelength; MEMO1. Lines.add (IntToStr (ilength)); While ilength>0 do Begin SetLength (buff, ilength); Ireceived: = Socket.receivebuf (buff[0], ilength); Ilength: = ilength-ireceived; End For i:=0 to ILength-1 do BEGIN S:=s+inttostr (Buff[i]); END; MEMO1. Lines.add (S); buff:= Nil; End
|
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
xhz8000
- xhz8000
-
This edition level:
|
#4 Score: from £ 2013-05-28 16:34:13 Procedure Tmainform. Tcpserver1clientread (Sender:tobject; Socket:tcustomwinsocket); Var Ilength,i,istart, Irevcount:integer; Ireceived:integer; Buff:array of Byte; s:string; Begin S:= "; IStart: = 0; Ilength:= socket.receivelength; Irevcount: = Ilength; Here to join SetLength (buff, ilength); MEMO1. Lines.add (IntToStr (ilength)); While ilength>0 do Begin Ireceived: = Socket.receivebuf (Buff[istart], ilength); The note is modified here IStart: = IStart + ireceived; Here to join Ilength: = Ilength-istart; End Below your ilength uses Irevcount to replace the For i:=0 to IRevCount-1 do BEGIN S:=s+inttostr (Buff[i]); END; MEMO1. Lines.add (S); buff:= Nil; End
|
| Useful to me [1] throw a brick [0] reference | Report | Management |
-
concern
-
Zyxip
- Zyxip
-
This edition level:
|
#5 Score: 0 replies.: 2013-05-29 12:13:32 Delphi/pascal Code?
| 12345678910111213 |
functionreceSocket(socket:TCustomWinSocket)var i,L:Integer; buff:Arrayof Byte;begin L:= Socket.ReceiveLength; ifL<=0then exit; SetLength(buff, L); i:= Socket.ReceiveBuf(buff[0], L); ifi<L then receSocket(Socket);end; |
Here are a few questions: you should create a buffer when receiving, push on receive, and pop when processing. Use a ring buffer. Do not display the interface at the same time when you receive it, unless your user volume and reception speed are very low. The problem with the TCP connection to handle sticky packets. |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#6 Score: 0 replies.: 2013-05-29 16:52:38 Reception problem 4 floor help me solve, thank you four floor. Now another question, why did I get an error sending the data: List index out of bounds (0)? The sending process is:
Procedure Tmainform. Button3click (Sender:tobject); Var s1:string; Begin S1:=memo2.seltext; S1:=stringreplace (S1, ",", [Rfreplaceall]); Tcpserver1.socket.connections[0]. SendText (S1); End |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#7 Score: 0 replies.: 2013-05-29 16:55:46 and socket.connections[0] in this sentence, [0] What is the role of |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#8 Score: 0 replies.: 2013-05-29 17:11:29SendText does not meet the requirements of the Statute, must be used socket.connections[i]. SendBuf (Buf,len), I'll try again. |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
xhz8000
- xhz8000
-
This edition level:
|
#9 Score: 0 replies.: 2013-05-29 17:31:13 You have to decide how many connections you have! If not connected then Tcpserver1.socket.connections[0] this will appear
What you said was wrong! |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#10 Score: 0 replies.: 2013-05-30 10:29:53 When sending a data frame: tcpserver1.socket.connections[0]. SendBuf (sdbuf,l); Why is it only possible to start sending from sdbuf[1]? If the data to be sent starts with sdbuf[0], then I will send a byte less |
| Useful to me [0] throw a brick [0] reference | Report | Management |
-
-
concern
-
xhz8000
- xhz8000
-
This level:
-
|
#11 Score: 0 reply to: 2013-05-30 11:10:50 sdbuf See how you define this! is an array of 0-based |
| useful to me [0] drop a brick [0] citation | report | manage |
-
concern
-
Zhengjiujie
- Zhengjiujie
-
This edition level:
|
#12 Score: 0 replies.: 2013-05-31 10:42:59 Thank you, and later found out that I defined sdbuf when I defined him as array[1..100] of byte. Thanks, upstairs. |
How Delphi's Tserversocket control receives 16 binary numbers