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
internal Socket socket;
16
public override void Open (AddressEntry entry)
18
string host, portStr, family;
21
if (!entry.Properties.TryGetValue ("host", out host))
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 + "\"");
30
if (!entry.Properties.TryGetValue ("family", out family))
33
Open (host, port, family);
36
public void Open (string host, int port, string family)
38
//TODO: use Socket directly
39
TcpClient client = new TcpClient (host, port);
41
client.NoDelay = true;
42
client.ReceiveBufferSize = (int)Protocol.MaxMessageLength;
43
client.SendBufferSize = (int)Protocol.MaxMessageLength;
45
this.socket = client.Client;
46
SocketHandle = (long)client.Client.Handle;
47
Stream = client.GetStream ();
50
public void Open (Socket socket)
54
socket.Blocking = true;
55
SocketHandle = (long)socket.Handle;
56
//Stream = new UnixStream ((int)socket.Handle);
57
Stream = new NetworkStream (socket);
60
public override void WriteCred ()
65
public override string AuthString ()