| 117 | } |
| 118 | |
| 119 | int SocketServerTCP::recv (void *data, int size) |
| 120 | { |
| 121 | if (connected_socket == INVALID_SOCKET) |
| 122 | { |
| 123 | return -1; |
| 124 | } |
| 125 | int res = ::recv (connected_socket, (char *)data, size, 0); |
| 126 | if (res == SOCKET_ERROR) |
| 127 | { |
| 128 | return -1; |
| 129 | } |
| 130 | for (int i = 0; i < res; i++) |
| 131 | { |
| 132 | temp_buffer.push (((char *)data)[i]); |
| 133 | } |
| 134 | // before we used SO_RCVLOWAT but it didnt work well |
| 135 | // and we were not sure that it works correctly with timeout |
| 136 | if (recv_all_or_nothing) |
| 137 | { |
| 138 | if ((int)temp_buffer.size () < size) |
| 139 | { |
| 140 | return 0; |
| 141 | } |
| 142 | for (int i = 0; i < size; i++) |
| 143 | { |
| 144 | ((char *)data)[i] = temp_buffer.front (); |
| 145 | temp_buffer.pop (); |
| 146 | } |
| 147 | return size; |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | for (int i = 0; i < res; i++) |
| 152 | { |
| 153 | ((char *)data)[i] = temp_buffer.front (); |
| 154 | temp_buffer.pop (); |
| 155 | } |
| 156 | return res; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | void SocketServerTCP::close () |
| 161 | { |
nothing calls this directly
no outgoing calls
no test coverage detected