A
abchjb
Unregistered / Unconfirmed
GUEST, unregistred user!
本人剛學習使用winsock.編寫一個簡單程序即出現錯誤;
想在Server端使用非阻塞方式,在Client端使用阻塞方式(也不知是否
可以),但在Client端沒法讀出數居;
procedure TForm1.Button1Click(Sender: TObject);
var
Ts:TWinSocketStream;
Buffer:string;
begin
cs.host:='localhost';
cs.Active:=True;
ts:=TWinSocketStream.Create(cs.socket,10000);
try
while cs.Active do
begin
buffer:='';
if ts.Read(Buffer, 4) = 0 then
begin
aaa1:='';
end
else
begin
aaa1:=buffer;
end;
Cs.Active:=False;
end;
finally
ts.Free;
end;
if aaa1 = '正式' then
Image1.Picture.LoadFromFile('c:/cao/wact/ok.bmp')
else if aaa1 = '錯誤' then
Image1.Picture.LoadFromFile('c:/cao/wact/aaa.bmp')
else if aaa1 = '沒有' then
Image1.Picture.LoadFromFile('c:/cao/wact/ccc.bmp');
caption:=aaa1;
end;
Sever端只是發送'正式'等漢字.
想在Server端使用非阻塞方式,在Client端使用阻塞方式(也不知是否
可以),但在Client端沒法讀出數居;
procedure TForm1.Button1Click(Sender: TObject);
var
Ts:TWinSocketStream;
Buffer:string;
begin
cs.host:='localhost';
cs.Active:=True;
ts:=TWinSocketStream.Create(cs.socket,10000);
try
while cs.Active do
begin
buffer:='';
if ts.Read(Buffer, 4) = 0 then
begin
aaa1:='';
end
else
begin
aaa1:=buffer;
end;
Cs.Active:=False;
end;
finally
ts.Free;
end;
if aaa1 = '正式' then
Image1.Picture.LoadFromFile('c:/cao/wact/ok.bmp')
else if aaa1 = '錯誤' then
Image1.Picture.LoadFromFile('c:/cao/wact/aaa.bmp')
else if aaa1 = '沒有' then
Image1.Picture.LoadFromFile('c:/cao/wact/ccc.bmp');
caption:=aaa1;
end;
Sever端只是發送'正式'等漢字.