Implement various WIN32 fixes

This commit is contained in:
Lion Kortlepel
2020-11-03 12:50:05 +01:00
parent f144d451c7
commit c5c21c43ad
5 changed files with 48 additions and 28 deletions

View File

@@ -11,7 +11,14 @@ void TCPSend(Client*c,const std::string&Data){
Assert(c);
if(c == nullptr)return;
std::string Send = "\n" + Data.substr(0,Data.find(char(0))) + "\n";
ssize_t Sent = send(c->GetTCPSock(), Send.c_str(), size_t(Send.size()), 0);
#ifdef WIN32
int Sent;
int len = static_cast<int>(Send.size());
#else
int64_t Sent;
size_t len = Send.size();
#endif // WIN32
Sent = send(c->GetTCPSock(), Send.c_str(), len, 0);
if (Sent == 0){
if(c->GetStatus() > -1)c->SetStatus(-1);
}else if (Sent < 0) {
@@ -37,7 +44,7 @@ void TCPRcv(Client*c){
char buf[4096];
size_t len = 4096;
ZeroMemory(buf, len);
ssize_t BytesRcv = recv(c->GetTCPSock(), buf, len,0);
int64_t BytesRcv = recv(c->GetTCPSock(), buf, len,0);
if (BytesRcv == 0){
debug(Sec("(TCP) Connection closing..."));
if(c->GetStatus() > -1)c->SetStatus(-1);