<font color=#ff00ff>那里出错了????????</font>(100分)

  • 主题发起人 主题发起人 dragon3000
  • 开始时间 开始时间
D

dragon3000

Unregistered / Unconfirmed
GUEST, unregistred user!
下面的是一个点对点聊天程序,可是连接时却跳出错误框,请各位大侠帮忙看看,是那里的错误,谢谢!!!!!

unit QQ;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, StdCtrls, ComCtrls, ToolWin, ImgList;
type
TForm1 = class(TForm)
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
Edit1: TEdit;
StatusBar1: TStatusBar;
Label1: TLabel;
ClientSocket1: TClientSocket;
ServerSocket1: TServerSocket;
memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocket1Accept(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure ToolButton3Click(Sender: TObject);
procedure ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
NickName:string;
b_Client:boolean;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
NickName:='我的昵称';
b_Client:=true;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
ClientSocket1.close;
ServerSocket1.open;
StatusBar1.SimpleText:='开始监听';
end;
procedure TForm1.ToolButton2Click(Sender: TObject);
var s:string;
begin
if Clientsocket1.Active then
ClientSocket1.close;
if InputQuery('连接到计算机','要连接的计算机名称或IP地址:',s) then
if Length(s)&gt;0 then
with ClientSocket1 do
begin
Host:=s;
open;
end;
end;
procedure TForm1.ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
begin
StatusBar1.SimpleText:='等待来自'+Socket.RemoteAddress+'的连接允许响应...';
end;
procedure TForm1.ServerSocket1Accept(Sender: TObject;
Socket: TCustomWinSocket);
begin
b_Client:=false;
StatusBar1.SimpleText:='连接到'+Socket.RemoteAddress;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
b_Client:=true;
StatusBar1.SimpleText:='连接成功';
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_Return then
begin
Memo1.Lines.Add(NickName+':'+Edit1.Text);
if b_Client then
ClientSocket1.Socket.SendText(Memo1.Lines[Memo1.lines.Count-1])
else
ServerSocket1.Socket.Connections[0].SendText(Memo1.Lines[Memo1.lines.Count-1]);
end;
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.lines.Add(Socket.ReceiveText);
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.lines.Add(Socket.ReceiveText);
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
begin
ClientSocket1.close;
StatusBar1.SimpleText:='断开连接';
end;
procedure TForm1.ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
ServerSocket1.close;
StatusBar1.SimpleText:='断开连接';
end;
procedure TForm1.ToolButton4Click(Sender: TObject);
var
s:string;
begin
if InputQuery('更改昵称','你的新昵称',s) then
if Length(s)&gt;0 then
NickName:=s;
end;
procedure TForm1.ToolButton5Click(Sender: TObject);
begin
ClientSocket1.close;
ServerSocket1.close;
Form1.close;
end;
end.
 
跳出什么错误框?
 
显示这样一个错误框:
projext QQp.exe raised exception class esocketerror with message'asynchronous socket error 10065'. process stopped. use step or run to continue.
 
有时候是error 11001
 
我试了一下,没什么问题。你是不是连接时直接打的机器名字?试试打ip。
 
我打ip地址也这样啊,不知怎么回事?
 
to zhhc
兄弟,能不能将你写的*.pas *.dpr 源程序打包给我发过来,谢谢!!
我的信箱 xiajj88@21cn.com
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=510201
 
后退
顶部