New test.
[mono.git] / mono / io-layer / sockets.c
index a580bfe3a09a46678a2b9f6b3dca98588d1136cc..5659c69762297e1ea261ed68f33525101cf5f8e6 100644 (file)
@@ -47,6 +47,8 @@ struct _WapiHandleOps _wapi_socket_ops = {
        NULL,                   /* signal */
        NULL,                   /* own */
        NULL,                   /* is_owned */
+       NULL,                   /* special_wait */
+       NULL                    /* prewait */
 };
 
 static mono_once_t socket_ops_once=MONO_ONCE_INIT;
@@ -98,7 +100,7 @@ int WSAStartup(guint32 requested, WapiWSAData *data)
        startup_count++;
 
        /* I've no idea what is the minor version of the spec I read */
-       data->wHighVersion = MAKEWORD(2,0);
+       data->wHighVersion = MAKEWORD(2,2);
        
        data->wVersion = requested < data->wHighVersion? requested:
                data->wHighVersion;
@@ -682,7 +684,8 @@ guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
 
        if (fd >= _wapi_fd_reserve) {
 #ifdef DEBUG
-               g_message ("%s: File descriptor is too big", __func__);
+               g_message ("%s: File descriptor is too big (%d >= %d)",
+                          __func__, fd, _wapi_fd_offset_table_size);
 #endif
 
                WSASetLastError (WSASYSCALLFAILURE);
@@ -792,9 +795,15 @@ WSAIoctl (guint32 fd, gint32 command,
        } else {
                /* We just copy the buffer to the output. Some ioctls
                 * don't even output any data, but, well...
+                *
+                * NB windows returns WSAEFAULT if o_len is too small
                 */
                i_len = (i_len > o_len) ? o_len : i_len;
-               memcpy (output, buffer, i_len);
+
+               if (i_len > 0 && output != NULL) {
+                       memcpy (output, buffer, i_len);
+               }
+               
                g_free (buffer);
                *written = i_len;
        }