Changeset 2253

Show
Ignore:
Timestamp:
21/08/2008 12:04:21 (3 months ago)
Author:
chris
Message:

Make Open() take a const std::string& for the socket name instead of a
const char *, for C++ style.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • box/trunk/lib/server/Socket.cpp

    r1783 r2253  
    3838// 
    3939// -------------------------------------------------------------------------- 
    40 void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type, const char *Name, int Port, int &rSockAddrLenOut) 
     40void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, 
     41        int Type, const std::string& rName, int Port, int &rSockAddrLenOut) 
    4142{ 
    4243        int sockAddrLen = 0; 
     
    4849                { 
    4950                        // Lookup hostname 
    50                         struct hostent *phost = ::gethostbyname(Name); 
     51                        struct hostent *phost = ::gethostbyname(rName.c_str()); 
    5152                        if(phost != NULL) 
    5253                        { 
     
    8283                { 
    8384                        // Check length of name is OK 
    84                         unsigned int nameLen = ::strlen(Name); 
     85                        unsigned int nameLen = rName.length(); 
    8586                        if(nameLen >= (sizeof(addr.sa_unix.sun_path) - 1)) 
    8687                        { 
     
    9293#endif 
    9394                        addr.sa_unix.sun_family = PF_UNIX; 
    94                         ::strcpy(addr.sa_unix.sun_path, Name); 
     95                        ::strcpy(addr.sa_unix.sun_path, rName.c_str()); 
    9596                } 
    9697                break; 
  • box/trunk/lib/server/Socket.h

    r217 r2253  
    4646        }; 
    4747 
    48         void NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type, const char *Name, int Port, int &rSockAddrLenOut); 
     48        void NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, 
     49                int Type, const std::string& rName, int Port, 
     50                int &rSockAddrLenOut); 
    4951        void LogIncomingConnection(const struct sockaddr *addr, socklen_t addrlen); 
    5052        std::string IncomingConnectionLogMessage(const struct sockaddr *addr, socklen_t addrlen); 
  • box/trunk/lib/server/SocketStream.cpp

    r2127 r2253  
    137137// 
    138138// -------------------------------------------------------------------------- 
    139 void SocketStream::Open(int Type, const char *Name, int Port) 
     139void SocketStream::Open(int Type, const std::string& rName, int Port) 
    140140{ 
    141141        if(mSocketHandle != INVALID_SOCKET_VALUE)  
     
    148148        SocketAllAddr addr; 
    149149        int addrLen = 0; 
    150         Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name, Port, addrLen); 
     150        Socket::NameLookupToSockAddr(addr, sockDomain, Type, rName, Port, addrLen); 
    151151 
    152152        // Create the socket 
     
    167167                ::closesocket(mSocketHandle); 
    168168                BOX_LOG_WIN_ERROR_NUMBER("Failed to connect to socket "  
    169                         "(type " << Type << ", name " << Name << 
     169                        "(type " << Type << ", name " << rName << 
    170170                        ", port " << Port << ")", err); 
    171171#else // !WIN32 
    172172                BOX_LOG_SYS_ERROR("Failed to connect to socket (type " << 
    173                         Type << ", name " << Name << ", port " << Port << 
     173                        Type << ", name " << rName << ", port " << Port << 
    174174                        ")"); 
    175175                ::close(mSocketHandle); 
  • box/trunk/lib/server/SocketStream.h

    r1085 r2253  
    3737        ~SocketStream(); 
    3838         
    39         void Open(int Type, const char *Name, int Port = 0); 
     39        void Open(int Type, const std::string& rName, int Port = 0); 
    4040        void Attach(int socket); 
    4141 
  • box/trunk/lib/server/SocketStreamTLS.cpp

    r2090 r2253  
    100100// 
    101101// -------------------------------------------------------------------------- 
    102 void SocketStreamTLS::Open(const TLSContext &rContext, int Type, const char *Name, int Port) 
    103 
    104         SocketStream::Open(Type, Name, Port); 
     102void SocketStreamTLS::Open(const TLSContext &rContext, int Type, 
     103        const std::string& rName, int Port) 
     104
     105        SocketStream::Open(Type, rName, Port); 
    105106        Handshake(rContext); 
    106107        ResetCounters(); 
  • box/trunk/lib/server/SocketStreamTLS.h

    r217 r2253  
    3939public: 
    4040 
    41         void Open(const TLSContext &rContext, int Type, const char *Name, int Port = 0); 
     41        void Open(const TLSContext &rContext, int Type, 
     42                const std::string& rName, int Port = 0); 
    4243        void Handshake(const TLSContext &rContext, bool IsServer = false); 
    4344