IdUDPClient发送数据,可不可以用目标机的 主机名 代替IP ?

rickys2080 2011-12-20 04:03:31
IdUDPClient发送数据,可不可以用目标机的 主机名 代替IP ?
现在用的方法是:
IdUDPClient1->Host = "172.16.113.220";
IdUDPClient1->Port = 8080;
IdUDPClient1->Send(s, NULL); //顺便问一下,此处的第二个参数是干嘛用的???
我希望将IP替换成目标机器的主机名(同一局域网下),如“PC_name”,请问如何实现?
谢谢
...全文
129 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rickys2080 2011-12-22
  • 打赏
  • 举报
回复
得,本机的主机名可以,一块ARM的不可以。。。
缘中人 2011-12-21
  • 打赏
  • 举报
回复
我手头没有2010,不过好像不推荐用这个了,bug多
rickys2080 2011-12-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ksrsoft 的回复:]

Host可以是IP,也可以是主机名称
Host is a String property used to identify the address of the remote computer system. Host and Port are used to build the UDP datagram packet, and identify the endpoint for the tr……
[/Quote]
但是我用主机名例如"myPC"它就报错啊
rickys2080 2011-12-20
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ksrsoft 的回复:]

你这个IdUDPClient是什么版本的,cb6中的没有这个定义啊
procedure Send(AData: string); overload;
[/Quote]
C++Builder2010 中的Indy版本应该是10吧,不同版本的Indy不兼容最要命了
缘中人 2011-12-20
  • 打赏
  • 举报
回复
你这个IdUDPClient是什么版本的,cb6中的没有这个定义啊
procedure Send(AData: string); overload;
缘中人 2011-12-20
  • 打赏
  • 举报
回复
Host可以是IP,也可以是主机名称
Host is a String property used to identify the address of the remote computer system. Host and Port are used to build the UDP datagram packet, and identify the endpoint for the transmission.
Host can contain an IP address in dotted-decimal form, such as "129.71.2.4", or a computer name, such as "wvnvm.wvnet.edu". If the destination is also the machine where the UDP client is running, use "127.0.0.1" in Host.

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧