Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2003-05-16 16:03:57 +0400
committerDick Porter <dick@acm.org>2003-05-16 16:03:57 +0400
commit88fba9d2396045ffded0af0e0fd047e8439855fc (patch)
tree84d723eb91c856b6610fc26ff43248d4c4114150 /mcs/class/System/System.Net.Sockets
parentfbc3d50964968d194be1e5f08790948999caf459 (diff)
2003-05-16 Dick Porter <dick@ximian.com>
* Socket.cs: Use Mono.Posix.UnixEndPoint if its available svn path=/trunk/mcs/; revision=14627
Diffstat (limited to 'mcs/class/System/System.Net.Sockets')
-rw-r--r--mcs/class/System/System.Net.Sockets/ChangeLog4
-rw-r--r--mcs/class/System/System.Net.Sockets/Socket.cs38
2 files changed, 42 insertions, 0 deletions
diff --git a/mcs/class/System/System.Net.Sockets/ChangeLog b/mcs/class/System/System.Net.Sockets/ChangeLog
index 254a53778e4..f1167857c0c 100644
--- a/mcs/class/System/System.Net.Sockets/ChangeLog
+++ b/mcs/class/System/System.Net.Sockets/ChangeLog
@@ -1,3 +1,7 @@
+2003-05-16 Dick Porter <dick@ximian.com>
+
+ * Socket.cs: Use Mono.Posix.UnixEndPoint if its available
+
2003-05-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* MulticastOption.cs: patch by Jerome Laban included in bug #42393.
diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs
index 941061863b7..9e370cf5e52 100644
--- a/mcs/class/System/System.Net.Sockets/Socket.cs
+++ b/mcs/class/System/System.Net.Sockets/Socket.cs
@@ -13,6 +13,8 @@ using System.Net;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Threading;
+using System.Reflection;
+using System.IO;
namespace System.Net.Sockets
{
@@ -261,6 +263,12 @@ namespace System.Net.Sockets
* the last IO operation
*/
private bool connected=false;
+
+ /* Used in LocalEndPoint and RemoteEndPoint if the
+ * Mono.Posix assembly is available
+ */
+ private static object unixendpoint=null;
+ private static Type unixendpointtype=null;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static void Select_internal(ref Socket[] read,
@@ -351,6 +359,30 @@ namespace System.Net.Sockets
}
}
+ static Socket() {
+ Assembly ass;
+
+ try {
+ ass=Assembly.Load("Mono.Posix");
+ } catch (FileNotFoundException) {
+ return;
+ }
+
+ unixendpointtype=ass.GetType("Mono.Posix.UnixEndPoint");
+
+ /* The endpoint Create() method is an instance
+ * method :-(
+ */
+ Type[] arg_types=new Type[1];
+ arg_types[0]=typeof(string);
+ ConstructorInfo cons=unixendpointtype.GetConstructor(arg_types);
+
+ object[] args=new object[1];
+ args[0]="";
+
+ unixendpoint=cons.Invoke(args);
+ }
+
// private constructor used by Accept, which already
// has a socket handle to use
private Socket(AddressFamily family, SocketType type,
@@ -435,6 +467,9 @@ namespace System.Net.Sockets
// Stupidly, EndPoint.Create() is an
// instance method
return new IPEndPoint(0, 0).Create(sa);
+ } else if (sa.Family==AddressFamily.Unix &&
+ unixendpoint!=null) {
+ return((EndPoint)unixendpointtype.InvokeMember("Create", BindingFlags.InvokeMethod|BindingFlags.Instance|BindingFlags.Public, null, unixendpoint, new object[] {sa}));
} else {
throw new NotImplementedException();
}
@@ -462,6 +497,9 @@ namespace System.Net.Sockets
// Stupidly, EndPoint.Create() is an
// instance method
return new IPEndPoint(0, 0).Create(sa);
+ } else if (sa.Family==AddressFamily.Unix &&
+ unixendpoint!=null) {
+ return((EndPoint)unixendpointtype.InvokeMember("Create", BindingFlags.InvokeMethod|BindingFlags.Instance|BindingFlags.Public, null, unixendpoint, new object[] {sa}));
} else {
throw new NotImplementedException();
}