为什么下面的程序会出错呢?哪里出错了?在线等待 ( 积分: 50 )

  • 主题发起人 主题发起人 adomy
  • 开始时间 开始时间
A

adomy

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
ServerSocket1: TServerSocket;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type TM_Server = class (TThread)
private
FServer:TServerSocket;
protected
procedure Execute();override;
Constructor Create();
// Destructor Destroy();
public
end;

type TM_Client = class (TThread)
private
FClient:TClientSocket;
protected
procedure Execute();override;
constructor Create();
// Destructor Destroy();
public
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
{ TM_Server }
constructor TM_Server.Create;
begin
FreeOnTerminate:=True;
FServer.ServerType:=stNonBlocking;
FServer.Port:=6666
end;
{
destructor TM_Server.Destroy;
begin
end;
}
procedure TM_Server.Execute;
begin
inherited;
FServer.Active:=True;
end;

{ TM_Client }
constructor TM_Client.Create;
begin
FreeOnTerminate:=True;
FClient.ClientType:=ctNonBlocking;
FClient.Address:='127.0.0.1';
FClient.Port:=6666;
FClient.Active:=True;
end;

{
destructor TM_Client.Destroy;
begin
end;
}
procedure TM_Client.Execute;
begin
inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
S:TM_Server;
begin
S:=TM_Server.Create;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
C:TM_Client;
begin
C:=TM_Client.Create;
end;

end.
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
ServerSocket1: TServerSocket;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type TM_Server = class (TThread)
private
FServer:TServerSocket;
protected
procedure Execute();override;
Constructor Create();
// Destructor Destroy();
public
end;

type TM_Client = class (TThread)
private
FClient:TClientSocket;
protected
procedure Execute();override;
constructor Create();
// Destructor Destroy();
public
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
{ TM_Server }
constructor TM_Server.Create;
begin
FreeOnTerminate:=True;
FServer.ServerType:=stNonBlocking;
FServer.Port:=6666
end;
{
destructor TM_Server.Destroy;
begin
end;
}
procedure TM_Server.Execute;
begin
inherited;
FServer.Active:=True;
end;

{ TM_Client }
constructor TM_Client.Create;
begin
FreeOnTerminate:=True;
FClient.ClientType:=ctNonBlocking;
FClient.Address:='127.0.0.1';
FClient.Port:=6666;
FClient.Active:=True;
end;

{
destructor TM_Client.Destroy;
begin
end;
}
procedure TM_Client.Execute;
begin
inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
S:TM_Server;
begin
S:=TM_Server.Create;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
C:TM_Client;
begin
C:=TM_Client.Create;
end;

end.
 
??、怎么没有人看啊?郁闷馁~~~~~~~~~
 
端口不能一样
冲突
可以试一下
 
内存泄漏
 
??我是要开个服务端的端口但是不能开6666端口啊!
FreeOnTerminate:=True;
FServer.ServerType:=stNonBlocking;
FServer.Port:=6666;
Fserver.active:=true;应该可以开的啊但是加在线程中为什么不开不了呢?
 
端口不能一样
冲突
可以试一下
 
后退
顶部