My method I use for my server pretty simple..
Code:struct Packet { unsigend short size; unsigned char opCode; char* data; };Code:Packet packet; fill it up... ...Code:int BytesToSend = sizeof(Packet); const char *pBytesToSend = (const char *)&packet; while (BytesToSend > 0) { int BytesSent = send(socket, pBytesToSend, BytesToSend, 0); if (BytesSent == SOCKET_ERROR) { int SockErr = WSAGetLastError(); if (SockErr != WSAEWOULDBLOCK) { // handle errors here break; } BytesSent = 0; } pBytesToSend += BytesSent; BytesToSend -= BytesSent; }




Reply With Quote