Own client/server and 10053 problem
-
Hello I got a client/server solution where I use IOPORTS in the server. Sometimes I get 10053 on WSASend/WSARecieve. Why do I get 10053 in the server, and how do I resolve it? Im not asking what the exact problem is, but to give me possible reasons that will help me to pinpoint the problem. "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error. " Doesnt help me that much.
-
Hello I got a client/server solution where I use IOPORTS in the server. Sometimes I get 10053 on WSASend/WSARecieve. Why do I get 10053 in the server, and how do I resolve it? Im not asking what the exact problem is, but to give me possible reasons that will help me to pinpoint the problem. "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error. " Doesnt help me that much.
-
Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.
-
Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.
-
Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.
The client that connects to you needs to set their own linger options before they connect to you. Same with your server app (you should set linger before you bind the socket).. I'm not sure if you can set that option after the socket has already been connected or after it accepts a connection.. One other thing (and im not 100% sure) but I dont think you need to call shutdown on a socket when it doesn't linger.. I think you can close the socket right away to free up the socket resoruces..
linger linger;
linger.l_onoff = TRUE;
linger.l_linger = 0;
setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof(struct linger));if(bind(server,(sockaddr*)&local,sizeof(local))!=0)
{
if(server != INVALID_SOCKET)
closesocket(server);MessageBox("Error Binding socket", "Socket Error", MB\_OK);
}
else
{
if(listen(server,10) != 0)
{
if(server != INVALID_SOCKET)
closesocket(server);etc.....
}Hope this gets you pointed in the right direction.. Rob Whoever said nothing's impossible never tried slamming a revolving door!