]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/sckaddr.cpp
another (last?) FreeBSD thread compilation fix
[wxWidgets.git] / src / common / sckaddr.cpp
index 801921e8aaecdb2f120b8ebc3112a7374a858bad..234a87005bc295be7ee71f552983ce58131cc556 100644 (file)
@@ -20,6 +20,8 @@
 #pragma hdrstop
 #endif
 
+#if wxUSE_SOCKETS
+
 #ifndef WX_PRECOMP
 #endif
 
 #endif // __WINDOWS__
 
 #if defined(__UNIX__)
-
 #ifdef VMS
 #include <socket.h>
 #include <in.h>
 #else
-#if defined(__FreeBSD__) || defined (__NetBSD__)
-#include <sys/types.h>
-#endif
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
 
 #ifdef __SUN__
-extern "C" {
-   int gethostname(char *name, int namelen);
+extern "C"
+{
+   struct hostent *gethostbyname(const char *name); 
+   int gethostname(char *name, int namelen); 
 };
 #endif
 
@@ -83,8 +83,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
 #endif
 
 wxIPV4address::wxIPV4address()
-  m_addr = new sockaddr_in;
 {
+  m_addr = new sockaddr_in;
   Clear();
 }
 
@@ -198,7 +198,11 @@ wxString wxIPV4address::Hostname()
 
   h_ent = gethostbyaddr((char *)&(m_addr->sin_addr), sizeof(m_addr->sin_addr),
                        GetFamily());
-  return wxString(h_ent->h_name);
+                       
+  if (!h_ent)
+     return wxString("");
+  else
+     return wxString(h_ent->h_name);
 }
 
 unsigned short wxIPV4address::Service()
@@ -416,3 +420,6 @@ void wxUNIXaddress::Disassemble(struct sockaddr *addr, size_t len)
   *m_addr = *(struct sockaddr_un *)addr;
 }
 #endif
+
+#endif 
+  // wxUSE_SOCKETS