Esempio n. 1
0
void LightweightConduit::sendBuffer(const NetAddress& a, BinaryOutput& b) {
    NetworkDevice* nd = NetworkDevice::instance();
    if (sendto(sock, (const char*)b.getCArray(), (int)b.size(), 0,
       (struct sockaddr *) &(a.addr), sizeof(a.addr)) == SOCKET_ERROR) {
        Log::common()->printf("Error occured while sending packet "
                             "to %s\n", inet_ntoa(a.addr.sin_addr));
        Log::common()->println(socketErrorCode());
        nd->closesocket(sock);
    } else {
        ++mSent;
        bSent += b.size();
    }
}
Esempio n. 2
0
void LightweightConduit::sendBuffer(const NetAddress& a, BinaryOutput& b) {
    if (sendto(sock, (const char*)b.getCArray(), b.size(), 0,
       (struct sockaddr *) &(a.addr), sizeof(a.addr)) == SOCKET_ERROR) {
        if (nd->debugLog) {
            nd->debugLog->printf("Error occured while sending packet "
                                 "to %s\n", inet_ntoa(a.addr.sin_addr));
            nd->debugLog->println(socketErrorCode());
        }
        nd->closesocket(sock);
    } else {
        ++mSent;
        bSent += b.size();
    }
}
Esempio n. 3
0
void ReliableConduit::sendBuffer(const BinaryOutput& b) {
    NetworkDevice* nd = NetworkDevice::instance();
    int ret = ::send(sock, (const char*)b.getCArray(), (int)b.size(), 0);
    
    if (ret == SOCKET_ERROR) {
        Log::common()->println("Error occured while sending message.");
        Log::common()->println(socketErrorCode());
        nd->closesocket(sock);
        return;
    }

    ++mSent;
    bSent += b.size();

    // Verify the packet was actually sent
    // Conversion to unsigned is safe because -1 is caught earlier
    debugAssert(ret == b.size());
}