void UdpReceivingSocket::OnReceive(int nErrorCode) { nRead = Receive(buff, 4096); icount1++; switch (nRead) { case 0: // Connection was closed. Close(); break; case SOCKET_ERROR: if (GetLastError() != WSAEWOULDBLOCK) { AfxMessageBox(L"Error occurred"); Close(); } break; default: // Normal case: Receive() returned the # of bytes received. buff[nRead] = 0; CAsyncSocket::OnReceive(nErrorCode); } .h file #pragma once #include <afxsock.h> #include "FILE_TRIALDlg.h" # include "TcpSendSocket.h" class UdpReceivingSocket : public CAsyncSocket { void OnReceive(int nErrorCode); public: UdpReceivingSocket(); ~UdpReceivingSocket(); BYTE buff[4096]; int nRead; };
PostMessage
SendMessage
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)