Exemplo n.º 1
0
static void ServerLoop(SOCKET s) {
    SOCKET connected;
    int active, quit = 0;
    message_t msg;

    do {
        if((connected = accept(s, NULL, NULL)) == INVALID_SOCKET)
            continue;

        if(ServerHandshake(connected) == 1) {
            active = 1;
            do {
                msg = CryptRecvMsg(connected);
                switch(msg.msg) {
                case MSG_PING:
                    CryptSendMsg(connected, MSG_PONG, 0);
                    break;
                case MSG_QUIN:
                    CryptSendMsg(connected, MSG_QUIN, ilevel);
                    break;
                case MSG_SLOG:
                    CryptSendMsg(connected, MSG_DATA, 0);
                    SendLog(connected);
                    break;
                case MSG_QUIT:
                    quit = 1;
                    CryptSendMsg(connected, MSG_ACK, 0);
                case MSG_ERR:
                    active = 0;
                    break;
                }
            } while(active);
        }

        closesocket(connected);

        if(conn.dh_remote_key) {
            free(conn.dh_remote_key);
            conn.dh_remote_key = NULL;
        }
        if(conn.dh_shared_key) {
            free(conn.dh_shared_key);
            conn.dh_shared_key = NULL;
        }
        if(conn.nonce) {
            free(conn.nonce);
            conn.nonce = NULL;
        }
    } while(!quit);
}
Exemplo n.º 2
0
void NET::Update()
{
	if (remote_socket == NULL)
		return;
	
	int retval = SDLNet_UDP_Recv(remote_socket, pin);
	
	if (retval >= 1 && connected)
	{
		BufferPacket(pin);
	}
	
	if (retval >= 1 && !connected)
	{
		ServerHandshake();
	}
}
Exemplo n.º 3
0
		void Socket::Connect( const std::string hostname, const unsigned short port ) {
			mSocket->Connect( hostname, port );
			ServerHandshake();
		}