133 int decodedLength = sizeof decodedPacket; |
133 int decodedLength = sizeof decodedPacket; |
134 HUFFMAN_Decode (reinterpret_cast<unsigned char*> (HuffmanBuffer), |
134 HUFFMAN_Decode (reinterpret_cast<unsigned char*> (HuffmanBuffer), |
135 decodedPacket, length, &decodedLength); |
135 decodedPacket, length, &decodedLength); |
136 datagram.address.host = ntohl (claddr.sin_addr.s_addr); |
136 datagram.address.host = ntohl (claddr.sin_addr.s_addr); |
137 datagram.address.port = ntohs (claddr.sin_port); |
137 datagram.address.port = ntohs (claddr.sin_port); |
138 datagram.message = Vector<unsigned char>(decodedPacket, decodedLength); |
138 datagram.message = ByteArray(decodedPacket, decodedLength); |
139 return true; |
139 return true; |
140 } |
140 } |
141 |
141 |
142 // ------------------------------------------------------------------------------------------------- |
142 // ------------------------------------------------------------------------------------------------- |
143 // |
143 // |
144 bool UDPSocket::send (const IPAddress& address, const Vector<unsigned char>& data) |
144 bool UDPSocket::send (const IPAddress& address, const ByteArray& data) |
145 { |
145 { |
146 int encodedlength = sizeof HuffmanBuffer; |
146 int encodedlength = sizeof HuffmanBuffer; |
147 HUFFMAN_Encode (data.data(), reinterpret_cast<unsigned char*> (HuffmanBuffer), data.size(), &encodedlength); |
147 HUFFMAN_Encode (data.data(), reinterpret_cast<unsigned char*> (HuffmanBuffer), data.size(), &encodedlength); |
148 sockaddr_in claddr = address.to_sockaddr_in(); |
148 sockaddr_in claddr = address.to_sockaddr_in(); |
149 int res = ::sendto (m_socket, HuffmanBuffer, encodedlength, 0, |
149 int res = ::sendto (m_socket, HuffmanBuffer, encodedlength, 0, |