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
;
10 namespace NDesk
.DBus
.Transports
12 class SocketTransport
: Transport
14 protected Socket socket
;
16 public override void Open (AddressEntry entry
)
21 if (!entry
.Properties
.TryGetValue ("host", out host
))
22 throw new Exception ("No host specified");
24 if (!entry
.Properties
.TryGetValue ("port", out portStr
))
25 throw new Exception ("No port specified");
27 if (!Int32
.TryParse (portStr
, out port
))
28 throw new Exception ("Invalid port: \"" + port
+ "\"");
33 public void Open (string host
, int port
)
35 //TODO: use Socket directly
36 TcpClient client
= new TcpClient (host
, port
);
37 Stream
= client
.GetStream ();
40 public void Open (Socket socket
)
44 socket
.Blocking
= true;
45 SocketHandle
= (long)socket
.Handle
;
46 //Stream = new UnixStream ((int)socket.Handle);
47 Stream
= new NetworkStream (socket
);
50 public override void WriteCred ()
55 public override string AuthString ()