Holy cow there's more to this than I thought lol. Oh well, a good learning experience. I guess at this point it would be much easier to combine some C++ because writing my own buffer handler in C might be tricky and dirty. But I do want to write a solid program that can handle anything so I will give it a shot.
Thanks again for your help.
Would this be an accurate way of handling the whole recv stuff:
Code:
if(FD_ISSET(out, &fd))
{
r = recv(out, buff, 1048576, 0);
if (r == SOCKET_ERROR)
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
{
closesocket(in);
closesocket(out);
puts("error@recv@thread@server");
break;
}
}
if (r != SOCKET_ERROR)
{
if (r > 0)
{
send(in, buff, r, 0);
/* will add handler later */
}
else
{
closesocket(in);
closesocket(out);
puts("server disconnected");
break;
}
}
}