J
Jelly0228
Unregistered / Unconfirmed
GUEST, unregistred user!
ClientSocket﹑ServerSocket組件。
都采用阻塞模式。
發送一個RichEdit的文本內容﹐為何這樣寫不行﹕
客戶端﹕
TClientThread.execute 過程﹕//TClientThread是從TThread派生下來的
SendStr:=TStringStream.Create('ok');
Form1.RichEdit1.Lines.SaveToStream(SendStr);
ClientSocket.Socket.SendStream(str);
服務端﹕
全局變量T:
T: TStringStream;
TServerThread.ClientExecute 過程﹕//從TServerClientThread派生下來
var
S:=TWinSocketStream;
While (not Terminated) and (ClientSocket.Connected) do
begin
S:= TWinSocketStream.Create(ClientSocket,60000);
T:=TStringStream.Create('AAAA');
S.seek(0,soFromBeginning);
T.CopyFrom(S,S.Size);
Synchronize(A過程);
//A過程的代碼是這樣的﹕Form2.RichEdit1.Lines.LoadFromStream(T)
end;
問題﹕
1.客戶端執行完ClientSocket.Socket.SendStream(str)后就不知道跑到哪兒去了﹐但當強行中斷程序后﹐就會跑到服務端來﹔
除非這樣寫才行﹕
A:=Form1.RichEdit1.Lines.Text;
ClientSocket.Socket.SendStream(TStringStream.Create(A));
2.服務端的文字流T也讀不到數據﹐﹐只能用ReadBuf讀。這是為什么呢??
都采用阻塞模式。
發送一個RichEdit的文本內容﹐為何這樣寫不行﹕
客戶端﹕
TClientThread.execute 過程﹕//TClientThread是從TThread派生下來的
SendStr:=TStringStream.Create('ok');
Form1.RichEdit1.Lines.SaveToStream(SendStr);
ClientSocket.Socket.SendStream(str);
服務端﹕
全局變量T:
T: TStringStream;
TServerThread.ClientExecute 過程﹕//從TServerClientThread派生下來
var
S:=TWinSocketStream;
While (not Terminated) and (ClientSocket.Connected) do
begin
S:= TWinSocketStream.Create(ClientSocket,60000);
T:=TStringStream.Create('AAAA');
S.seek(0,soFromBeginning);
T.CopyFrom(S,S.Size);
Synchronize(A過程);
//A過程的代碼是這樣的﹕Form2.RichEdit1.Lines.LoadFromStream(T)
end;
問題﹕
1.客戶端執行完ClientSocket.Socket.SendStream(str)后就不知道跑到哪兒去了﹐但當強行中斷程序后﹐就會跑到服務端來﹔
除非這樣寫才行﹕
A:=Form1.RichEdit1.Lines.Text;
ClientSocket.Socket.SendStream(TStringStream.Create(A));
2.服務端的文字流T也讀不到數據﹐﹐只能用ReadBuf讀。這是為什么呢??