I'm working on an application using the net-snmp library (net-snmp-5.6-2). And being curious, I took a look at the source code :-). Doing so I've mentioned the use of errno to get information about failed calls to WinSock. For example in snmpUDPBaseDomain.c:
... rc = sendto(t->sock, buf, size, 0, to, sizeof(struct sockaddr)); ... if (rc < 0 && errno != EINTR) { DEBUGMSGTL(("netsnmp_udp", "sendto error, rc %d (errno %d)\n", rc, errno)); Having done a little bit of coding with socket interfaces on a few platforms, I think that using errno on platforms close to UNIX is perfect but is not good on Windows. With Windows you have to use WSAGetLastError() (and error codes that start with WSA* e.g. WSAEINTR for EINTR) instead of errno. As I can't find any occurrence of WSAGetLastError in the source code of net-snmp lib, I can't think of any preprocessor-/overload- or whatever-trick to get socket errors from something called errno. I also checked that my knowledge about WinSock and WSAGetLastError() is correct and found an article here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms737828%28v=vs.85%29.aspx Is there any other trick to use errno for socket calls on Windows? Or is this a bug? I haven't checked every occurrence of errno, but it seems that it is mainly used in debug message, so the bug might be of no relevance. Regards, Walter Schmoll ##################################################################################### This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. Thank You. ANDRITZ HYDRO GmbH Rechtsform/ Legal form: Gesellschaft mit beschr?nkter Haftung / Corporation Firmensitz/ Registered seat: Wien Firmenbuchgericht/ Court of registry: Handelsgericht Wien Firmenbuchnummer/ Company registration: FN 61833 g DVR: 0605077 UID-Nr.: ATU14756806 ##################################################################################### ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders