* list :
[mono.git] / mono / metadata / socket-io.c
index c3cd2264088c73658b8db1f1a0dd9ea587675b4c..aba200d31c5e5c8fa1c37197dd484ce5f14704bc 100644 (file)
@@ -12,6 +12,7 @@
 #include <glib.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include <mono/metadata/object.h>
 #include <mono/io-layer/io-layer.h>
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>     /* defines FIONBIO and FIONREAD */
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>    /* defines SIOCATMARK */
+#endif
+
 
 #undef DEBUG
 
@@ -512,7 +520,10 @@ void ves_icall_System_Net_Sockets_Socket_Close_internal(SOCKET sock)
 
 gint32 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal(void)
 {
+#ifdef DEBUG
        g_message(G_GNUC_PRETTY_FUNCTION ": returning %d", WSAGetLastError());
+#endif
+
        return(WSAGetLastError());
 }
 
@@ -1279,7 +1290,7 @@ static gboolean hostent_to_IPHostEntry(struct hostent *he, MonoString **h_name,
        return(TRUE);
 }
 
-extern gboolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list)
+extern MonoBoolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list)
 {
        char *hostname;
        struct hostent *he;
@@ -1334,7 +1345,7 @@ inet_pton (int family, const char *address, void *inaddrp)
 }
 #endif /* !HAVE_INET_PTON */
 
-extern gboolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list)
+extern MonoBoolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list)
 {
        struct in_addr inaddr;
        struct hostent *he;
@@ -1353,6 +1364,22 @@ extern gboolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr
        return(hostent_to_IPHostEntry(he, h_name, h_aliases, h_addr_list));
 }
 
+extern MonoBoolean ves_icall_System_Net_Dns_GetHostName_internal(MonoString **h_name)
+{
+       guchar hostname[256];
+       int ret;
+       
+       ret=gethostname (hostname, sizeof(hostname));
+       if(ret==-1) {
+               return(FALSE);
+       }
+       
+       *h_name=mono_string_new(mono_domain_get (), hostname);
+
+       return(TRUE);
+}
+
+
 void mono_network_init(void)
 {
        WSADATA wsadata;