急死我了 100大洋求解(100分)

  • 主题发起人 主题发起人 fff-1
  • 开始时间 开始时间
F

fff-1

Unregistered / Unconfirmed
GUEST, unregistred user!
我在写一个聊天程序在进行连接时老进行拨号连接,稍后显示错误
" windows socket error: (11004),on API'ASync Lookup "
急死我了 100大洋求解
错误含义,如何解决,避免拨号连接
 
1104错误是:合法名字,但无要求类型的数据记录。
你把源码贴出来一下。
 
源码如下
............
var
Form1: TForm1;
history:tinifile;
myname,yourname,ip,sendtext,receivetext:string;


implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.N1Click(Sender: TObject);
begin
form2.show;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if(key=vk_return)then
begin
richedit1.Lines.Add(myname+' 说:"'+edit1.text+'" '+timetostr(time));
clientsocket1.socket.sendtext(edit1.text);
edit1.clear;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
history:=tinifile.create('c:/web.ini');
myname:=history.readstring('name','name','');
ip:=history.readstring('ip','ip','');
serversocket1.Open;
end;

procedure TForm1.ServerSocket1Accept(Sender: TObject;
Socket: TCustomWinSocket);
begin
yourname:=socket.receivetext;
treeview1.items.add(treeview1.selected,yourname);
treeview1.FullExpand;
richedit1.lines.add('欢迎'+yourname+'加入聊天'+' '+timetostr(time));
clientsocket1.socket.sendtext(myname);
end;

procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
receivetext:=socket.receivetext;
richedit1.Lines.add(receivetext);
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
clientsocket1.Socket.sendtext(myname);
end;

procedure TForm1.ToolButton1Click(Sender: TObject);
begin
clientsocket1.host:=ip;
clientsocket1.Active:=true;
serversocket1.active:=true;
clientsocket1.Open;
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
showmessage('无法建立连接');
end;

end.

ip地址等均已正确填写

 
将问题提前
 
>>clientsocket1.host:=ip;
如果你的ip变量真是IP地址的话,把IP地址赋值给host还能不错?
应该是clientsocket1.address:=ip;
 
9494,
clientsocket1.address:=ip
clientsocket1.host:=host name
 
多人接受答案了。
 
//faint!!

老猫你经常砍歪 :-)
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部