det er på serveren fejlen kommer.
Serverkoden er her:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ServerSocket1: TServerSocket;
Memo1: TMemo;
ClientSocket1: TClientSocket;
ListBox1: TListBox;
Button1: TButton;
Timer1: TTimer;
procedure ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('client tilsluttet');
listbox1.Items.add(serversocket1.Socket.Remoteaddress);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
serversocket1.active:=true;
end;
end.
Klientkoden er her:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ScktComp;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Connection1: TMenuItem;
Options1: TMenuItem;
Commands1: TMenuItem;
quit1: TMenuItem;
Logfield: TMemo;
Cmdline: TEdit;
Listuser: TListBox;
Connectandregister1: TMenuItem;
Disconnect1: TMenuItem;
Register1: TMenuItem;
Connect1: TMenuItem;
Status1: TMenuItem;
ServerSocket1: TServerSocket;
ClientSocket1: TClientSocket;
procedure quit1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Connectandregister1Click(Sender: TObject);
procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.quit1Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Showmessage('tak for sidst');
end;
procedure TForm1.Connectandregister1Click(Sender: TObject);
begin
logfield.lines.add('Connecting and registering');
clientsocket1.port:=9334;
clientsocket1.host:='127.0.0.1';
clientsocket1.open;
end;
procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
logfield.lines.add('Error connecting to server, try again later');
end;
end.
mvh
Lars