我用花生壳申请动态解析了个域名
路由设置如下http://image155.poco.cn/mypoco/myphoto/20090827/12/534922962009082712300003_640.jpg
我电脑的mac 和 ip
开启映射的端口
我测试的程序{Client}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, StdCtrls,
WinSock;type
TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetIp(DNS: string): string;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);//连接server
begin
while IdTCPClient1.Connected = False do
begin
IdTCPClient1.Connect();
end;
if IdTCPClient1.Connected = true then
showmessage('connected');
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPClient1.Host := GetIp('cole-pfieffer.gicp.net'); //'192.168.1.105';//'127.0.0.1';连接localhost可行
IdTCPClient1.Port := 5050;
Edit1.Text := IdTCPClient1.Host;
end;function TForm1.GetIp(DNS: string): string;//解析域名获得ip
var
So:TWsadata;
begin
WSAStartup($202, So);
Result:=iNet_ntoa(PInAddr(GetHostByName(PAnsichar(DNS))^.h_addr_list^)^);
end;
end.
{Server}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdContext, StdCtrls, IdBaseComponent, IdComponent, IdCustomTCPServer,
IdTCPServer;type
TForm1 = class(TForm)
IdTCPServer1: TIdTCPServer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure IdTCPServer1Execute(AContext: TIdContext);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);//启动server
begin
while IdTCPServer1.Active = False do
begin
IdTCPServer1.Active :=True;
end;
Form1.Caption := 'Server Actived'
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPServer1.DefaultPort := 5050;
end;procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
begin
form1.Caption:='server';
end;end.域名是我自己的电脑 我用adsl+tplink路由器
host换成127.0.0.1或192.168.1.105可以连接,解析域名的连不上服务器,我判断是端口映射没有设置好 但找不到原因 防火墙是关了的 xp系统
小弟菜鸟 望大虾不吝赐教
路由设置如下http://image155.poco.cn/mypoco/myphoto/20090827/12/534922962009082712300003_640.jpg
我电脑的mac 和 ip
开启映射的端口
我测试的程序{Client}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, StdCtrls,
WinSock;type
TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetIp(DNS: string): string;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);//连接server
begin
while IdTCPClient1.Connected = False do
begin
IdTCPClient1.Connect();
end;
if IdTCPClient1.Connected = true then
showmessage('connected');
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPClient1.Host := GetIp('cole-pfieffer.gicp.net'); //'192.168.1.105';//'127.0.0.1';连接localhost可行
IdTCPClient1.Port := 5050;
Edit1.Text := IdTCPClient1.Host;
end;function TForm1.GetIp(DNS: string): string;//解析域名获得ip
var
So:TWsadata;
begin
WSAStartup($202, So);
Result:=iNet_ntoa(PInAddr(GetHostByName(PAnsichar(DNS))^.h_addr_list^)^);
end;
end.
{Server}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdContext, StdCtrls, IdBaseComponent, IdComponent, IdCustomTCPServer,
IdTCPServer;type
TForm1 = class(TForm)
IdTCPServer1: TIdTCPServer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure IdTCPServer1Execute(AContext: TIdContext);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);//启动server
begin
while IdTCPServer1.Active = False do
begin
IdTCPServer1.Active :=True;
end;
Form1.Caption := 'Server Actived'
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPServer1.DefaultPort := 5050;
end;procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
begin
form1.Caption:='server';
end;end.域名是我自己的电脑 我用adsl+tplink路由器
host换成127.0.0.1或192.168.1.105可以连接,解析域名的连不上服务器,我判断是端口映射没有设置好 但找不到原因 防火墙是关了的 xp系统
小弟菜鸟 望大虾不吝赐教
解决方案 »
- dbadvstringgrid中怎放一单选列
- 大家有没有用19#宽屏做软件开发的
- Delphi中Indy控件关于ReadBuffer问题,加急!
- 现在win平台下ado连接sql2000数据库,要把数据库服务器换成Linux,客户端是不是还可用win平台,程序要改哪些?
- 在delphi7 中的sql语句
- 大虾!入门的小鬼来问问题了?
- MDIForm只创建单一窗体
- 求救:如何获取网卡的MAC地址?
- delphi 编程把若干个汉字用拼音拼写出来
- 如果开发工具是Delphi,600bps的带宽下你,采用那种架构阿?(高手来看)
- 如何将UTF-8的文本文件转换成Ansi或者unicode
- 有关fastreport的groupheader
你用PING能PING到你输入的IP吗?
不成功说明端口映射有问题
否则再找其他的问题
郁闷
telnet 5050端口连不上
如果不通的话,就是路由的问题了
我认为就是端口映射没做好 但就是找不到原因
好奇怪啊