| 86 | } |
| 87 | |
| 88 | bool ConnClass::write(int count, uint8_t* buf) { |
| 89 | if (!connectionOpen) { return false; } |
| 90 | std::lock_guard lck(writeMtx); |
| 91 | int ret; |
| 92 | |
| 93 | if (_udp) { |
| 94 | int fromLen = sizeof(remoteAddr); |
| 95 | ret = sendto(_sock, (char*)buf, count, 0, (struct sockaddr*)&remoteAddr, sizeof(remoteAddr)); |
| 96 | } |
| 97 | else { |
| 98 | ret = send(_sock, (char*)buf, count, 0); |
| 99 | } |
| 100 | |
| 101 | if (ret <= 0) { |
| 102 | { |
| 103 | std::lock_guard lck(connectionOpenMtx); |
| 104 | connectionOpen = false; |
| 105 | } |
| 106 | connectionOpenCnd.notify_all(); |
| 107 | } |
| 108 | return (ret > 0); |
| 109 | } |
| 110 | |
| 111 | void ConnClass::readAsync(int count, uint8_t* buf, void (*handler)(int count, uint8_t* buf, void* ctx), void* ctx) { |
| 112 | if (!connectionOpen) { return; } |
no outgoing calls
no test coverage detected