L
loskiller
Unregistered / Unconfirmed
GUEST, unregistred user!
服务端部分代码:
TFileServerThread=class(TServerClientThread)
public
procedure ClientExecute;override;
end;
procedure TFileServerThread.ClientExecute;
var
r:shortint;
begin
inherited;
r:=-3;
self.ClientSocket.SendBuf(r,1);
self.ClientSocket.Close;
end;
s:=TServerSocket.Create(nil);
s.ServerType:=stThreadBlocking;
s.Port:=13013;
s.OnGetThread:=DOOnGetThread;
s.Active:=true;
procedure TForm1.DOOnGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
SocketThread:=TFileServerThread.Create(false,ClientSocket);
end;
客户端代码:
procedure TForm1.Button1Click(Sender: TObject);
var
b:shortint;
begin
b:=0;
c:=TClientSocket.Create(self);
c.Address:='127.0.0.1';
c.ClientType:=ctBlocking;
c.Port:=13013;
c.Active:=true;
c.Socket.SendText('abc');
c.Socket.ReceiveBuf(b,1);
c.Close;
c.Free;
showmessage(inttostr(b));
end;
当运行客户端时,代码走到 c.Socket.ReceiveBuf(b,1);这里就不动了。郁闷啊。
TFileServerThread=class(TServerClientThread)
public
procedure ClientExecute;override;
end;
procedure TFileServerThread.ClientExecute;
var
r:shortint;
begin
inherited;
r:=-3;
self.ClientSocket.SendBuf(r,1);
self.ClientSocket.Close;
end;
s:=TServerSocket.Create(nil);
s.ServerType:=stThreadBlocking;
s.Port:=13013;
s.OnGetThread:=DOOnGetThread;
s.Active:=true;
procedure TForm1.DOOnGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
SocketThread:=TFileServerThread.Create(false,ClientSocket);
end;
客户端代码:
procedure TForm1.Button1Click(Sender: TObject);
var
b:shortint;
begin
b:=0;
c:=TClientSocket.Create(self);
c.Address:='127.0.0.1';
c.ClientType:=ctBlocking;
c.Port:=13013;
c.Active:=true;
c.Socket.SendText('abc');
c.Socket.ReceiveBuf(b,1);
c.Close;
c.Free;
showmessage(inttostr(b));
end;
当运行客户端时,代码走到 c.Socket.ReceiveBuf(b,1);这里就不动了。郁闷啊。