当我试图在那个套接字中接收数据时,我似乎总是得到这个特别的消息。套接字是一个有效的套接字,并且建立了连接,并且总是有一些数据周期性地出现在指定端口中。但是recv函数如何给出这个错误。知道原因是什么吗?
下面是示例代码。
提前谢谢
struct hostent *hdata; // Used when Node name is converted to IP-Address
struct sockaddr_in insock; // Socket address structure
unsigned long ipaddr; // IP-Address in numeric format
CString sIPAddr = _T("1.1.1.1");
char * cSBCS = (char*)sIPAddr.GetBuffer(sIPAddr.GetLength());
ipaddr = inet_addr( cSBCS/*sIPAddr*/ );
hdata = gethostbyname( sIPAddr );
insock.sin_family = AF_INET;
insock.sin_port = htons( 2101 );
memcpy( &insock.sin_addr, *(hdata->h_addr_list), hdata->h_length );
// Create socket
if(( m_Socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP )) == INVALID_SOCKET );
// return FALSE;
// Connect to MSS-box
if(( connect( m_Socket, (struct sockaddr *)&insock, sizeof( insock ))) == SOCKET_ERROR )
DWORD dwNonBlocking = -1;
if( ioctlsocket( m_Socket, FIONBIO, &dwNonBlocking ))
如果((pdwrxchars=recv(m_socket,prxbuffer,1024,0))==socket_error)
总是获取wsaewouldblock错误