?
=?ISO-8859-1?Q?Herbert_VON_GR=DCNENWALD?=
hi everyone,
i've made a client/server class in C++ and some other to do the same
thing in c#.
clients and server works fine, in the two langages, but there is one
problem when a c++ client disconnect from the c# server:
- the connection is OK
- when i send a message from the client to the server, no problems (it
is received by the server)
- but when i shutdown and close the client (c++) (code below, there is
no error at run time), the server receive some data:
-------------------------------------------------
byte[] nb = new byte[4];
received = socket.Receive(nb, 0, 4, System.Net.Sockets.SocketFlags.None);
or
received = socket.Receive(nb);
-------------------------------------------------
the result is the same:
received = 0
and this function receive 0 bytes, 10000-100000 times !!
so i doesn't understand very well what's happenning !
have you any ideas ?
thanks
there the code when closing the client
-------------------------------------------------
int CManuWinSock::Close()
{
int iret = 0;
if (m_socket != INVALID_SOCKET)
{
iret = shutdown(m_socket, SD_BOTH);
if (iret)
{
erreur(WSAGetLastError(), "CManuWinSock::Close shutdown");
}
iret = closesocket(m_socket);
if (iret)
{
erreur(WSAGetLastError(), "CManuWinSock::Close closesocket");
return iret;
}
else
m_socket = INVALID_SOCKET;
}
return iret;
}
-------------------------------------------------
i've made a client/server class in C++ and some other to do the same
thing in c#.
clients and server works fine, in the two langages, but there is one
problem when a c++ client disconnect from the c# server:
- the connection is OK
- when i send a message from the client to the server, no problems (it
is received by the server)
- but when i shutdown and close the client (c++) (code below, there is
no error at run time), the server receive some data:
-------------------------------------------------
byte[] nb = new byte[4];
received = socket.Receive(nb, 0, 4, System.Net.Sockets.SocketFlags.None);
or
received = socket.Receive(nb);
-------------------------------------------------
the result is the same:
received = 0
and this function receive 0 bytes, 10000-100000 times !!
so i doesn't understand very well what's happenning !
have you any ideas ?
thanks
there the code when closing the client
-------------------------------------------------
int CManuWinSock::Close()
{
int iret = 0;
if (m_socket != INVALID_SOCKET)
{
iret = shutdown(m_socket, SD_BOTH);
if (iret)
{
erreur(WSAGetLastError(), "CManuWinSock::Close shutdown");
}
iret = closesocket(m_socket);
if (iret)
{
erreur(WSAGetLastError(), "CManuWinSock::Close closesocket");
return iret;
}
else
m_socket = INVALID_SOCKET;
}
return iret;
}
-------------------------------------------------