|
发表于 2008-4-22 17:30:47
|
显示全部楼层
ACE_INET_Addr有一个构造函数满足你的要求:
/**
* Initializes an ACE_INET_Addr from the <address>, which can be
* "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or
* "128.252.166.57:1234"). If there is no ':' in the <address> it
* is assumed to be a port number, with the IP address being
* INADDR_ANY.
*/
explicit ACE_INET_Addr (const char address[],
int address_family = AF_UNSPEC);
调用方式就很简单了三,
ACE_INET_Addr addr("192.168.1.233:21", AF_INET);
同时,还有一个set()函数也可以做同样的操作:
/**
* Initializes an ACE_INET_Addr from the @a addr, which can be
* "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or
* "128.252.166.57:1234"). If there is no ':' in the <address> it
* is assumed to be a port number, with the IP address being
* INADDR_ANY.
*/
int set (const char addr[], int address_family = AF_UNSPEC);
调用方式如下:
ACE_INET_Addr addr;
addr.set("192.168.1.233:21", AF_INET);
[ 本帖最后由 earthdog 于 2008-4-22 17:32 编辑 ] |
|