TCP Problem : Error 10045
I declare a socket with WSASocket( AF_INET, SOCK_STREAM, 0, 0, 0, WSA_FLAG_OVERLAPPED ) and don''t set any other properties to it. Then I connect() the socket to a remote server, which always return successfully. Then I try to post recieve buffers with WSARecv, but always get error #10045, wich is "Operation not supported on socket". I was under the impression that WSARecv/WSASend support both blocking/nonblocking sockets. Am I forgetting to set a flag somewhere?
Can you post your code? Post the code you used to assign an invalid socket to a new socket or an incoming socket.
Kuphryn
Kuphryn
Here is where I create a socket.
//-----------------------------------------------------------
// create socket
conn->m_ConnectionInfo.hSocket = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_IP, NULL, WSA_FLAG_OVERLAPPED );
//-----------------------------------------------------------
I also tried using IPPROTO_TCP for the protocol type. No luck.
Here is where I connect.
//-----------------------------------------------------------
m_ConnectionInfo.address.sin_family = AF_INET;
m_ConnectionInfo.address.sin_port = pAddress->GetPort();
m_ConnectionInfo.address.sin_addr = *((in_addr*)&dwAddress);
// connect to the remote server
iRet = connect( m_ConnectionInfo.hSocket, (sockaddr*)m_ConnectionInfo.address, sizeof(sockaddr) );
//-----------------------------------------------------------
Everything works fine here, but fails here on WSARecv.
//-----------------------------------------------------------
deTCPOVERLAPPED * over = new deTCPOVERLAPPED();
DWORD dwSize;
DWORD dwFlags;
SOCKET s = this->GetConnectionInfo().hSocket;
// fill out overlapped structure
over->bCompleted = false;
over->bSuccessful = false;
over->dwFlags = 0;
over->dwOrgSize = 0;
over->hSocket = s;
over->iNumBuffers = 1;
over->pBuffers = GetFreeBuffer();
over->pConn = this; // connection object
deASSERT( over->pBuffers );
// queue an I/O operation
iRet = WSARecv( s, over->pBuffers, 1, &dwSize, &dwFlags, (LPWSAOVERLAPPED)over, OnRecvComplete );
//-----------------------------------------------------------
it fails with error 10045.
//-----------------------------------------------------------
// create socket
conn->m_ConnectionInfo.hSocket = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_IP, NULL, WSA_FLAG_OVERLAPPED );
//-----------------------------------------------------------
I also tried using IPPROTO_TCP for the protocol type. No luck.
Here is where I connect.
//-----------------------------------------------------------
m_ConnectionInfo.address.sin_family = AF_INET;
m_ConnectionInfo.address.sin_port = pAddress->GetPort();
m_ConnectionInfo.address.sin_addr = *((in_addr*)&dwAddress);
// connect to the remote server
iRet = connect( m_ConnectionInfo.hSocket, (sockaddr*)m_ConnectionInfo.address, sizeof(sockaddr) );
//-----------------------------------------------------------
Everything works fine here, but fails here on WSARecv.
//-----------------------------------------------------------
deTCPOVERLAPPED * over = new deTCPOVERLAPPED();
DWORD dwSize;
DWORD dwFlags;
SOCKET s = this->GetConnectionInfo().hSocket;
// fill out overlapped structure
over->bCompleted = false;
over->bSuccessful = false;
over->dwFlags = 0;
over->dwOrgSize = 0;
over->hSocket = s;
over->iNumBuffers = 1;
over->pBuffers = GetFreeBuffer();
over->pConn = this; // connection object
deASSERT( over->pBuffers );
// queue an I/O operation
iRet = WSARecv( s, over->pBuffers, 1, &dwSize, &dwFlags, (LPWSAOVERLAPPED)over, OnRecvComplete );
//-----------------------------------------------------------
it fails with error 10045.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement