Changeset 14 in libcf++ for trunk/src/network.cpp


Ignore:
Timestamp:
06/13/15 18:44:16 (9 years ago)
Author:
cheese
Message:

#1 interface for connection with address/port

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/network.cpp

    r13 r14  
    155155cf::bool_t cf::network::host::empty() const
    156156{
    157     return (address().empty() || port() <= 0) ? true : false;
     157    return (address().empty() || port() == 0) ? true : false;
    158158}
    159159
     
    209209    throw (cf::exception)
    210210{
    211     if (peer.empty())
    212         THROW_EXCEPTION("invalid host info");
    213 
     211    connect(peer.address(), peer.port(), timeout);
     212}
     213
     214cf::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{
    214219    cf::int32_t result = 0;
    215220    cf::int32_t retval = 0;
     
    218223    struct hostent * hostEnt;
    219224
    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();
    222226
    223227    /* 1. set data */
     
    353357    cf::int32_t size = static_cast<cf::int32_t>(in.size());
    354358
    355     cf::int32_t sentSize = (cf::int32_t)::send (mSocket, buf, size, 0);
     359    cf::int32_t sentSize = (cf::int32_t)::send(mSocket, buf, size, 0);
    356360    if (sentSize != size)
    357361        THROW_EXCEPTION("cannot send (" << cf::exception::systemCode() << ")");
Note: See TracChangeset for help on using the changeset viewer.