Changeset 812

Show
Ignore:
Timestamp:
04/30/06 14:55:38 (4 years ago)
Author:
ahu
Message:

implement 'netstringerror', to be called to report network errors

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/misc.cc

    r802 r812  
    329329} 
    330330 
     331#ifdef WIN32 
     332string netstringerror() 
     333{ 
     334  char buf[512]; 
     335  int err=WSAGetLastError(); 
     336  if(FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 
     337                     0, buf, sizeof(buf)-1, NULL)) { 
     338    return string(buf); 
     339  } 
     340  else { 
     341    return strerror(err); 
     342  } 
     343} 
     344#else 
     345string netstringerror() 
     346{ 
     347  return stringerror(); 
     348} 
     349#endif 
     350 
    331351void cleanSlashes(string &str) 
    332352{ 
  • trunk/pdns/pdns/misc.hh

    r802 r812  
    150150string U32ToIP(uint32_t); 
    151151string stringerror(); 
     152string netstringerror(); 
    152153string itoa(int i); 
    153154string uitoa(unsigned int i); 
  • trunk/pdns/pdns/pdns_recursor.cc

    r810 r812  
    827827     
    828828    int fd=socket(sin.sin4.sin_family, SOCK_DGRAM,0); 
    829     if(fd<0)  
    830       throw AhuException("Making a UDP server socket for resolver: "+stringerror()); 
     829    if(fd < 0) { 
     830      throw AhuException("Making a UDP server socket for resolver: "+netstringerror()); 
     831    } 
    831832 
    832833    setReceiveBuffer(fd, 200000);