A few more

This commit is contained in:
2025-02-20 14:33:07 -06:00
parent 6e09919639
commit 9c21fe26a4

View File

@@ -157,9 +157,8 @@ namespace Socket {
int status = 0;
int total_sent = 0;
unsigned int left_to_send = length;
while(total_sent < length)
{
status = ::send(mSock, buff + total_sent, left_to_send, flags);
while(total_sent < length) {
status = ::send(mSock, reinterpret_cast<const char*>(buff + total_sent), left_to_send, flags);
if (status == -1)
CheckErrors_send(errno);
else {
@@ -172,7 +171,7 @@ namespace Socket {
bool TcpSocket_Old::Receive(u8* msg, int len, int flags)
{
int status = 0;
if ((status = ::recv(mSock, msg, len, flags)) == -1)
if ((status = ::recv(mSock, reinterpret_cast<char*>(msg), len, flags)) == -1)
CheckErrors_recv(errno);
else if (status == 0)
return false;
@@ -182,12 +181,19 @@ namespace Socket {
void TcpSocket_Old::Close()
{
#if defined(__linux__) || defined(__APPLE__)
//::shutdown(mSock, 2);
if (::close(mSock) == -1)
CheckErrors_close(errno);
else
mClosed = true;
#elif defined(_WIN32)
if (::closesocket(mSock == -1))
CheckErrors_close(errno);
else
mClosed = true;
#endif
}
// Private:
void TcpSocket_Old::setInfo(int port)
@@ -236,11 +242,19 @@ namespace Socket {
} address;
socklen_t addressSize = sizeof(sockaddr_storage);
int newSock;
#if defined(__linux__) || defined(__APPLE__)
if ((newSock = ::accept(mSock, (struct sockaddr *) 0, (unsigned int *) 0)) == -1) {
//if ((newSock = ::accept(mSock, (sockaddr*)&address.s, &addressSize)) == -1) {
jlog::Debug(strerror(errno));
CheckErrors_accept(errno);
}
#elif defined(_WIN32)
if ((newSock = ::accept(mSock, (struct sockaddr *) 0, (int *) 0)) == -1) {
//if ((newSock = ::accept(mSock, (sockaddr*)&address.s, &addressSize)) == -1) {
jlog::Debug(strerror(errno));
CheckErrors_accept(errno);
}
#endif
jlog::Debug("1 client accepted");
addrinfo info;