1
// Copyright 2006 Alp Toker <alp@atoker.com>
2
// This software is made available under the MIT License
3
// See COPYING for details
8
using System.Net.Sockets;
11
using Mono.Unix.Native;
13
namespace NDesk.DBus.Transports
15
class UnixMonoTransport : UnixTransport
17
protected Socket socket;
19
public override void Open (string path, bool @abstract)
22
socket = OpenAbstractUnix (path);
24
socket = OpenUnix (path);
26
socket.Blocking = true;
27
SocketHandle = (long)socket.Handle;
28
//Stream = new UnixStream ((int)socket.Handle);
29
Stream = new NetworkStream (socket);
32
//send peer credentials null byte. note that this might not be portable
33
//there are also selinux, BSD etc. considerations
34
public override void WriteCred ()
39
public override string AuthString ()
41
long uid = UnixUserInfo.GetRealUserId ();
43
return uid.ToString ();
46
protected Socket OpenAbstractUnix (string path)
48
AbstractUnixEndPoint ep = new AbstractUnixEndPoint (path);
50
Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
56
public Socket OpenUnix (string path)
58
UnixEndPoint remoteEndPoint = new UnixEndPoint (path);
60
Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
61
client.Connect (remoteEndPoint);