示例#1
0
int CFtpTransfer::Receive(const int client_sockfd) {
    long int n;
    char buffer[BUFFER_SIZE];
    bzero(buffer,BUFFER_SIZE);
    n = ReceiveLine(client_sockfd,buffer,BUFFER_SIZE);
    if(n > 0){
        cout << "From client command: " << buffer << endl;
        CClient *pClient = m_ClientManager.FindClient(client_sockfd);
        if(pClient){
            CCommand *pCommand = m_ClientManager.FindCommand(string(buffer));
            if(pCommand){
                pCommand->doWhat(pClient);
                EFTPSTATE state = pClient->GetClientState();
                if(state == QUIT){
                    m_ClientManager.EarseClient(client_sockfd);
                    m_CurrentConnetions--;
                    //cout << "one con disconnected and current con is: " << m_CurrentConnetions << endl;
                }
            }
            else{
                pClient->sendErrorMsg();
            }
        }
    }
    else{
        m_ClientManager.EarseClient(client_sockfd);
        m_CurrentConnetions--;
        //cout << "one con disconnected and current con is: " << m_CurrentConnetions << endl;
    }
}