132 int decodedLength = sizeof decodedPacket; |
132 int decodedLength = sizeof decodedPacket; |
133 ::HUFFMAN_Decode(reinterpret_cast<unsigned char*>(HuffmanBuffer), |
133 ::HUFFMAN_Decode(reinterpret_cast<unsigned char*>(HuffmanBuffer), |
134 decodedPacket, length, &decodedLength); |
134 decodedPacket, length, &decodedLength); |
135 datagram.address.host = ntohl(claddr.sin_addr.s_addr); |
135 datagram.address.host = ntohl(claddr.sin_addr.s_addr); |
136 datagram.address.port = ntohs(claddr.sin_port); |
136 datagram.address.port = ntohs(claddr.sin_port); |
137 datagram.message = ByteArray{&decodedPacket[0], &decodedPacket[decodedLength]}; |
137 datagram.message = std::vector<unsigned char>{&decodedPacket[0], &decodedPacket[decodedLength]}; |
138 return true; |
138 return true; |
139 } |
139 } |
140 |
140 |
141 bool net::UDPSocket::send(const net::ip_address& address, const ByteArray& data, std::ostream& errors) |
141 bool net::UDPSocket::send(const net::ip_address& address, const std::vector<unsigned char>& data, std::ostream& errors) |
142 { |
142 { |
143 int encodedlength = sizeof HuffmanBuffer; |
143 int encodedlength = sizeof HuffmanBuffer; |
144 ::HUFFMAN_Encode(data.data(), reinterpret_cast<unsigned char*>(HuffmanBuffer), data.size(), &encodedlength); |
144 ::HUFFMAN_Encode(data.data(), reinterpret_cast<unsigned char*>(HuffmanBuffer), data.size(), &encodedlength); |
145 sockaddr_in claddr = net::ip_address_to_sockaddr_in(address); |
145 sockaddr_in claddr = net::ip_address_to_sockaddr_in(address); |
146 const int send_result = ::sendto( |
146 const int send_result = ::sendto( |