Changeset 19 in chevmsgr


Ignore:
Timestamp:
11/23/15 23:39:17 (8 years ago)
Author:
cheese
Message:

init -> setSocket / setKey 로 나눔
msg.hpp 에서 SecureSocket::close 함수 수정, 기본 생성자 수정

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/msg.hpp

    r18 r19  
    178178
    179179public :
    180     SecureSocket() {}
     180    SecureSocket()
     181    {
     182        sock = NULL;
     183    }
    181184    SecureSocket(cf::network::tcp * sock, const std::string & ip, const std::string & sms)
    182185    {
    183         init(sock, ip, sms);
    184     }
    185 
    186     void init(cf::network::tcp * sock, const std::string & ip, const std::string & sms)
     186        setSocket(sock);
     187        setKey(ip, sms);
     188    }
     189
     190    void setSocket(cf::network::tcp * sock)
    187191    {
    188192        this->sock = sock;
    189 
     193    }
     194
     195    void setKey(const std::string & ip, const std::string & sms)
     196    {
    190197        cf::bin seed = sms + DELIMITER + ip;
    191198        cf::bin key = crypto().sha256(seed);
     
    206213    void close()
    207214    {
    208         sock->close();
     215        if (sock)
     216            sock->close();
    209217    }
    210218};
  • trunk/msgsrv.cpp

    r18 r19  
    590590int main(int argc, char ** argv)
    591591{
    592     if (argc != 2)
     592    if (argc != 3)
    593593    {
    594594        std::cerr << "-_-^" << std::endl;
Note: See TracChangeset for help on using the changeset viewer.