N
netbug
Unregistered / Unconfirmed
GUEST, unregistred user!
我用TClientSocket与TServerSocket分别写了两个小程序,
这是服务器端的:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;Socket: TCustomWinSocket);
var cBuffer:array [1..4096] of char;
i,iLen:integer;
begin
memo1.Lines.Add(socket.receivetext);
iLen:=socket.ReceiveLength;
edit1.Text:=inttostr(ilen);
socket.ReceiveBuf(cBuffer,iLen);
edit2.Text:=cBuffer;
end;
第二个是客户端的:
procedure TForm1.ClientSocket1Write(Sender: TObject;
Socket: TCustomWinSocket);
begin
socket.SendText('hello');
end;
我在本地机做了测试,发现在服务器端memo1中有
收到客户端发送的字符串'hello',但令我感到
奇怪的是:在服务器端socket.ReceiveLength为0,
cBuffer也不是客户端发送的字符串'hello',
我想问:起码还有'hello',socket.ReceiveLength长度怎么会为0?
socket.receivetext与socket.ReceiveBuf
有什么不同吗?谢谢.
这是服务器端的:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;Socket: TCustomWinSocket);
var cBuffer:array [1..4096] of char;
i,iLen:integer;
begin
memo1.Lines.Add(socket.receivetext);
iLen:=socket.ReceiveLength;
edit1.Text:=inttostr(ilen);
socket.ReceiveBuf(cBuffer,iLen);
edit2.Text:=cBuffer;
end;
第二个是客户端的:
procedure TForm1.ClientSocket1Write(Sender: TObject;
Socket: TCustomWinSocket);
begin
socket.SendText('hello');
end;
我在本地机做了测试,发现在服务器端memo1中有
收到客户端发送的字符串'hello',但令我感到
奇怪的是:在服务器端socket.ReceiveLength为0,
cBuffer也不是客户端发送的字符串'hello',
我想问:起码还有'hello',socket.ReceiveLength长度怎么会为0?
socket.receivetext与socket.ReceiveBuf
有什么不同吗?谢谢.