Hi, Err.. forgot to attach the patch...
Attached patch adds conversion of SocketFlags to linux flags required for _wapi_recv, _wapi_recvfrom, _wapi_send, _wapi_sendto calls. I'm not sure how to handle these flags though: DontRoute MaxIOVectorLength Partial Also, the patch adds handling of SocketOption.Error for getsockopt which isn't handled in the existing code. Regards, Ankit
Index: mono/metadata/socket-io.c =================================================================== --- mono/metadata/socket-io.c (revision 41272) +++ mono/metadata/socket-io.c (working copy) @@ -1125,6 +1125,7 @@ buf=mono_array_addr(buffer, guchar, offset); + recvflags = socketflags_to_flags (flags); ret = _wapi_recv (sock, buf, count, recvflags); if(ret==SOCKET_ERROR) { *error = WSAGetLastError (); @@ -1159,6 +1160,7 @@ buf=mono_array_addr(buffer, guchar, offset); + recvflags = socketflags_to_flags (flags); ret = _wapi_recvfrom (sock, buf, count, recvflags, sa, &sa_size); if(ret==SOCKET_ERROR) { g_free(sa); @@ -1206,6 +1208,7 @@ g_message(G_GNUC_PRETTY_FUNCTION ": Sending %d bytes", count); #endif + sendflags = socketflags_to_flags (flags); ret = _wapi_send (sock, buf, count, sendflags); if(ret==SOCKET_ERROR) { *error = WSAGetLastError (); @@ -1248,6 +1251,7 @@ g_message(G_GNUC_PRETTY_FUNCTION ": Sending %d bytes", count); #endif + sendflags = socketflags_to_flags (flags); ret = _wapi_sendto (sock, buf, count, sendflags, sa, sa_size); if(ret==SOCKET_ERROR) { *error = WSAGetLastError (); @@ -1472,6 +1476,11 @@ * int getsockopt will error, causing an exception) */ switch(name) { + case SocketOptionName_Error: + ret = _wapi_getsockopt (sock, system_level, system_name, &val, + &valsize); + break; + case SocketOptionName_Linger: case SocketOptionName_DontLinger: ret = _wapi_getsockopt(sock, system_level, system_name, &linger, @@ -1502,6 +1511,12 @@ } switch(name) { + case SocketOptionName_Error: + if (val > 0) + val = errno_to_WSA (val, NULL); + obj = int_to_object (domain, val); + break; + case SocketOptionName_Linger: /* build a System.Net.Sockets.LingerOption */ obj_class=mono_class_from_name(system_assembly, Index: mono/io-layer/sockets.c =================================================================== --- mono/io-layer/sockets.c (revision 41272) +++ mono/io-layer/sockets.c (working copy) @@ -539,6 +539,35 @@ return(0); } +int socketflags_to_flags (int flags) +{ + int recvflags =0; + + switch (flags) { + case 0x00000001: + //OutOfBand + recvflags = MSG_OOB; + break; + case 0x00000002: + //Peek + recvflags = MSG_PEEK; + break; + case 0x00000004: + //DontRoute + case 0x00000010: + //MaxIOVectorLength + case 0x00008000: + //Partial + recvflags = 0; //?? + break; + default: + recvflags = 0; + break; + } + + return recvflags; +} + int _wapi_recv(guint32 fd, void *buf, size_t len, int recv_flags) { return(_wapi_recvfrom(fd, buf, len, recv_flags, NULL, 0));