if(!g_onlyTCP) {
Socket udpsock(g_dest.sin4.sin_family, SOCK_DGRAM);
- udpsock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), g_dest);
+ udpsock.sendTo(string(packet.begin(), packet.end()), g_dest);
ComboAddress origin;
res = waitForData(udpsock.getHandle(), 0, 1000 * g_timeoutMsec);
if(res < 0)
sock.connect(g_dest);
uint16_t len = htons(packet.size());
string tcppacket((char*)& len, 2);
- tcppacket.append((char*)&*packet.begin(), (char*)&*packet.end());
+ tcppacket.append(packet.begin(), packet.end());
sock.writen(tcppacket);
if(sock.write((char *) &len, 2) != 2)
throw PDNSException("tcp write failed");
- sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+ sock.writen(string(packet.begin(), packet.end()));
if(sock.read((char *) &len, 2) != 2)
throw PDNSException("tcp read failed");
len = htons(packet.size());
if(sock.write((char *) &len, 2) != 2)
throw PDNSException("tcp write failed");
- sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+ sock.writen(string((char*)&packet[0], packet.size()));
if(sock.read((char *) &len, 2) != 2)
throw PDNSException("tcp read failed");
if(sock.write((char *) &len, 2) != 2)
throw PDNSException("tcp write failed");
- sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+ sock.writen(string(packet.begin(), packet.end()));
bool isNSEC3 = false;
int soacount=0;
if(sock.write((char *) &len, 2) != 2)
throw PDNSException("tcp write failed");
- sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+ sock.writen(string(packet.begin(), packet.end()));
if(sock.read((char *) &len, 2) != 2)
throw PDNSException("tcp read failed");
else //udp
{
Socket sock(dest.sin4.sin_family, SOCK_DGRAM);
- sock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), dest);
+ sock.sendTo(string(packet.begin(), packet.end()), dest);
int result=waitForData(sock.getHandle(), 10);
if(result < 0)
throw std::runtime_error("Error waiting for data: "+string(strerror(errno)));
if(d_rsock.write((char *) &len, 2) != 2)
throw PDNSException("tcp write failed");
- d_rsock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+ d_rsock.writen(string(packet.begin(), packet.end()));
int bread=d_rsock.read((char *) &len, 2);
if( bread <0)