yoni1993
December 1st, 2007, 07:10 AM
i didnt worked on socket for about 5 months and now i tried to build a server and client but i mistook something on the base:
I tried to send a byte to the server but the server act like that is nothing received;
Client:
SocketA = new Socket();
SocketA->Create();
SocketA->Connect("127.0.0.1", 2157);
byte f = 0x01;
SocketA->Send(&f, 1);
Server Socket Class:
void Socket::OnReceive(int nErrorCode)
{
byte g;
MessageBox(hwnd, "OnReceive", "Info" , MB_OK);
Receive(&g, 1);
::SendMessage(hwnd, WM_RECV, 0, 0);
CSocket::OnReceive(nErrorCode);
}
void Socket::OnAccept(int nErrorCode)
{
MessageBox(hwnd, "Accepted", "Info" , MB_OK);
CSocket::OnAccept(nErrorCode);
}
Server Listen:
SocketA.hwnd = GetSafeHwnd();
SocketA.Create(2157);
SocketA.Listen();
So, when im connecting to the server, i get a messagebox about accept but for OnReceive nothing happen !
Why ?
thank you for any help.
I tried to send a byte to the server but the server act like that is nothing received;
Client:
SocketA = new Socket();
SocketA->Create();
SocketA->Connect("127.0.0.1", 2157);
byte f = 0x01;
SocketA->Send(&f, 1);
Server Socket Class:
void Socket::OnReceive(int nErrorCode)
{
byte g;
MessageBox(hwnd, "OnReceive", "Info" , MB_OK);
Receive(&g, 1);
::SendMessage(hwnd, WM_RECV, 0, 0);
CSocket::OnReceive(nErrorCode);
}
void Socket::OnAccept(int nErrorCode)
{
MessageBox(hwnd, "Accepted", "Info" , MB_OK);
CSocket::OnAccept(nErrorCode);
}
Server Listen:
SocketA.hwnd = GetSafeHwnd();
SocketA.Create(2157);
SocketA.Listen();
So, when im connecting to the server, i get a messagebox about accept but for OnReceive nothing happen !
Why ?
thank you for any help.