TCP - 超时客户端的身份

时间:2014-04-07 01:28:04

标签: tcp timeout client

我想知道超时客户的身份? 怎么样?

如果函数将接收这样的数据..我怎么知道客户端ID?

非常感谢您的帮助

谢谢:)

   DWORD WINAPI Server::ClientThread(LPVOID lpParam)

    {


             char receivedData[BUFFER_SIZE];
             ThreadData  myThreadData = *(ThreadData*)lpParam;
             while (1)
             {
                 int returnValue;
                 // Perform a blocking recv() call
                 returnValue = recv(myThreadData.clientSocket, receivedData, BUFFER_SIZE, 0);

                 if (returnValue == 0)
                     break;
                 else if (returnValue == SOCKET_ERROR)
                 {
                     cout << "recv() failed - Error Code : " << WSAGetLastError() << endl;

                 }
                 else
                 {
                     receivedData[returnValue] = '\0';
                     cout << "I am the server and received " << receivedData << endl;
                     UnderstandComingMessage(receivedData, myThreadData);
                 }



             }
}

1 个答案:

答案 0 :(得分:0)

我不知道你的身份是什么意思,但你可以通过调用套接字上的getpeername()来获取对等IP地址和端口。