L
lovenuo
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是服务器端的代码,用客户端连接服务器端,发送数据A时,发生错误!
unit U_Server;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
ServerSocket1: TServerSocket;
StatusBar1: TStatusBar;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Enabled:=False;
Button2.Enabled:=True;
Button3.Enabled:=True;
ServerSocket1.Port:=8098;
ServerSocket1.Active:=True;
StatusBar1.SimpleText:='服务器已成功启动!'
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button1.Enabled:=True;
Button2.Enabled:=False;
ServerSocket1.Active:=False;
StatusBar1.SimpleText:='服务器已成功停止!'
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
ss:string;
begin
sfengbao:=ServerSocket1.Socket.ReceiveText;
if pos('A',ss)<>0 then
begin
ServerSocket1.Socket.SendText('22');
end;
end;
end.
下面是错误的图片,知道的,加我QQ 55754344
unit U_Server;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
ServerSocket1: TServerSocket;
StatusBar1: TStatusBar;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Enabled:=False;
Button2.Enabled:=True;
Button3.Enabled:=True;
ServerSocket1.Port:=8098;
ServerSocket1.Active:=True;
StatusBar1.SimpleText:='服务器已成功启动!'
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button1.Enabled:=True;
Button2.Enabled:=False;
ServerSocket1.Active:=False;
StatusBar1.SimpleText:='服务器已成功停止!'
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
ss:string;
begin
sfengbao:=ServerSocket1.Socket.ReceiveText;
if pos('A',ss)<>0 then
begin
ServerSocket1.Socket.SendText('22');
end;
end;
end.
下面是错误的图片,知道的,加我QQ 55754344