Changeset 14 in libcf++
- Timestamp:
- 06/13/15 18:44:16 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf/network.h
r11 r14 101 101 102 102 /** 103 * connect to address:port103 * connect to host 104 104 * @param peer peer host 105 105 * @param timeout timeout … … 107 107 */ 108 108 cf::void_t connect(const host & peer, 109 const cf::int32_t timeout = 0) 110 throw (cf::exception); 111 112 /** 113 * connect to address:port 114 * @param address address 115 * @param port port 116 * @param timeout timeout 117 * @throw cf::exception 118 */ 119 cf::void_t connect(const std::string & address, 120 const cf::uint16_t port, 109 121 const cf::int32_t timeout = 0) 110 122 throw (cf::exception); -
trunk/src/network.cpp
r13 r14 155 155 cf::bool_t cf::network::host::empty() const 156 156 { 157 return (address().empty() || port() <= 0) ? true : false;157 return (address().empty() || port() == 0) ? true : false; 158 158 } 159 159 … … 209 209 throw (cf::exception) 210 210 { 211 if (peer.empty()) 212 THROW_EXCEPTION("invalid host info"); 213 211 connect(peer.address(), peer.port(), timeout); 212 } 213 214 cf::void_t cf::network::tcp::connect(const std::string & address, 215 const cf::uint16_t port, 216 const cf::int32_t timeout) 217 throw (cf::exception) 218 { 214 219 cf::int32_t result = 0; 215 220 cf::int32_t retval = 0; … … 218 223 struct hostent * hostEnt; 219 224 220 const cf::char_t * host = peer.address().c_str(); 221 cf::uint16_t port = peer.port(); 225 const cf::char_t * host = address.c_str(); 222 226 223 227 /* 1. set data */ … … 353 357 cf::int32_t size = static_cast<cf::int32_t>(in.size()); 354 358 355 cf::int32_t sentSize = (cf::int32_t)::send 359 cf::int32_t sentSize = (cf::int32_t)::send(mSocket, buf, size, 0); 356 360 if (sentSize != size) 357 361 THROW_EXCEPTION("cannot send (" << cf::exception::systemCode() << ")");
Note:
See TracChangeset
for help on using the changeset viewer.