bool Socket::close() { if (is_valid()) { tcp_close(_sd); _sd = INVALID_SOCKET; osCleanup(); return true; } return false; }
bool Socket::close() { if (is_valid()) { if (_sd != SOCKET_ERROR) #ifdef TARGET_WINDOWS closesocket(_sd); #else ::close(_sd); #endif _sd = INVALID_SOCKET; osCleanup(); return true; } return false; }
int Socket::sendto ( const char* data, unsigned int size, bool sendcompletebuffer) { int sentbytes = 0; int i; do { i = ::sendto(_sd, data, size, 0, (const struct sockaddr*) &_sockaddr, sizeof( _sockaddr ) ); if (i <= 0) { errormessage( getLastError(), "Socket::sendto"); osCleanup(); return i; } sentbytes += i; } while ( (sentbytes < (int) size) && (sendcompletebuffer == true)); return i; }
Socket::~Socket() { close(); osCleanup(); }