|
我是一个ACE的初学者,正在<ACE 技术论文集>.在看书的过程中出现了一些问题。请大侠帮忙看看。
书上有个例子是这样的:- static const nt PORT_NUM = 10000;
- static const int TIMEOUT =5;
- // SOCK_SAP Client.
- template <class CONNECTOR>
- void send_data (CONNECTOR::PEER_ADDR peer_addr)
- {
- // Data transfer object.
- CONNECTOR::PEER_STREAM peer_stream;
- // Establish connection without blocking.
- CONNECTOR connector (peer_stream, peer_addr, ACE_NONBLOCK);
- if (peer_stream.get_handle () == -1)
- {
- // If non-blocking connection is in progress,
- // wait up to TIMEOUT seconds to complete.
- Time_Value timeout (TIMEOUT);
- if (errno != EWOULDBLOCK ||
- connector.complete (peer_stream, peer_addr, &timeout) == -1)
- perror ("connector"), exit (1);
- }
- char buf[BUFSIZ];
- for (int r_bytes; (r_bytes = read (0, buf, sizeof buf)) > 0;)
- peer_stream.send_n (buf, r_bytes);
- // Explicitly close the connection.
- peer_stream.close ();
- }
- int main (intargc, char *argv[])
- {
- char *host = argc > 1 ? argv[1] : "ics.uci.edu";
- u_short port_num = htons (argc > 2 ? atoi (argv[2]) : PORT_NUM);
- // Address ofthe server.
- ACE_INET_Addr s_addr (port_num, host)
- // Use SOCK SAP wrappers onclient’s side.
- send_data <ACE_SOCK_Connector> (s_addr);
- return 0;
- }
复制代码 代码的意思都是懂的,但是突然想编译看看结果,结果发现问题:
if (peer_stream.get_handle () == -1) 这里==-1报错,类型无法转换。
CONNECTOR connector (peer_stream, peer_addr, ACE_NONBLOCK); 这里也是说ACE_NONBLOCK不能换成ACE_Time_Value,我郁闷了。对这个不熟,改都不知怎么改。请大侠帮帮忙? |
|