~ubuntu-branches/debian/jessie/banshee-community-extensions/jessie

« back to all changes in this revision

Viewing changes to .pc/0001-Use-DBus-instead-of-NDesk.DBus.patch/src/Telepathy/Banshee.Telepathy/NDesk.DBus/SocketTransport.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-09-20 18:45:46 UTC
  • mfrom: (1.2.9 upstream) (5.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20110920184546-3ahue2qplydc4t0e
Tags: 2.2.0-1
* [4940fab] Imported Upstream version 2.2.0
  + Notable bug fixes:
    - Karaoke: Fix crash when switching to Now Playing
    - Lyrics: Fix crash when switching to Now Playing

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006 Alp Toker <alp@atoker.com>
2
 
// This software is made available under the MIT License
3
 
// See COPYING for details
4
 
 
5
 
using System;
6
 
using System.IO;
7
 
using System.Net;
8
 
using System.Net.Sockets;
9
 
 
10
 
namespace NDesk.DBus.Transports
11
 
{
12
 
        class SocketTransport : Transport
13
 
        {
14
 
                internal Socket socket;
15
 
 
16
 
                public override void Open (AddressEntry entry)
17
 
                {
18
 
                        string host, portStr, family;
19
 
                        int port;
20
 
 
21
 
                        if (!entry.Properties.TryGetValue ("host", out host))
22
 
                                host = "localhost";
23
 
 
24
 
                        if (!entry.Properties.TryGetValue ("port", out portStr))
25
 
                                throw new Exception ("No port specified");
26
 
 
27
 
                        if (!Int32.TryParse (portStr, out port))
28
 
                                throw new Exception ("Invalid port: \"" + port + "\"");
29
 
 
30
 
                        if (!entry.Properties.TryGetValue ("family", out family))
31
 
                                family = null;
32
 
 
33
 
                        Open (host, port, family);
34
 
                }
35
 
 
36
 
                public void Open (string host, int port, string family)
37
 
                {
38
 
                        //TODO: use Socket directly
39
 
                        TcpClient client = new TcpClient (host, port);
40
 
                        /*
41
 
                        client.NoDelay = true;
42
 
                        client.ReceiveBufferSize = (int)Protocol.MaxMessageLength;
43
 
                        client.SendBufferSize = (int)Protocol.MaxMessageLength;
44
 
                        */
45
 
                        this.socket = client.Client;
46
 
                        SocketHandle = (long)client.Client.Handle;
47
 
                        Stream = client.GetStream ();
48
 
                }
49
 
 
50
 
                public void Open (Socket socket)
51
 
                {
52
 
                        this.socket = socket;
53
 
 
54
 
                        socket.Blocking = true;
55
 
                        SocketHandle = (long)socket.Handle;
56
 
                        //Stream = new UnixStream ((int)socket.Handle);
57
 
                        Stream = new NetworkStream (socket);
58
 
                }
59
 
 
60
 
                public override void WriteCred ()
61
 
                {
62
 
                        Stream.WriteByte (0);
63
 
                }
64
 
 
65
 
                public override string AuthString ()
66
 
                {
67
 
                        return String.Empty;
68
 
                }
69
 
        }
70
 
}