src/proto2/Network.cc
branchno-netsession
changeset 38 4189b8bf3a5b
parent 37 ed2957490bbf
equal deleted inserted replaced
37:ed2957490bbf 38:4189b8bf3a5b
     1 
     1 
     2 #include "Network.hh"
     2 #include "Network.hh"
     3 #include "NetworkAddress.hh"
     3 #include "NetworkAddress.hh"
       
     4 #include "NetworkSocket.hh"
     4 #include "Engine.hh"
     5 #include "Engine.hh"
       
     6 
       
     7 #include <sstream>
       
     8 #include <cstring>
     5 
     9 
     6 std::ostream& operator<< (std::ostream &s, const NetworkAddress &addr) {
    10 std::ostream& operator<< (std::ostream &s, const NetworkAddress &addr) {
     7     s << "[" << addr.get_address() << ":" << addr.get_port() << "]";
    11     s << "[" << addr.get_address() << ":" << addr.get_port() << "]";
     8 
    12 
     9     return s;
    13     return s;
    10 
    14 
    11 }
    15 }
       
    16         
       
    17 std::string NetworkSocketError::build_str (const NetworkSocket &socket, const char *op, const char *err) {
       
    18     std::stringstream ss;
       
    19 
       
    20     ss << "socket #" << socket.get_socket() << " " << op << ": " << err;
       
    21 
       
    22     return ss.str();
       
    23 }
       
    24 
       
    25 NetworkSocketError::NetworkSocketError (const NetworkSocket &socket, const char *op, const char *err) :
       
    26     Error(build_str(socket, op, err)) {
       
    27     
       
    28     // nothing
       
    29 }
       
    30