0002-Improve-tcp-connection-establishment_531bea6.patch

S. Barut, 10/01/2018 02:12 PM

Download (2.74 KB)

View differences:

rsb-cil-test/Program.cs
12 12
{
13 13
    class MainClass
14 14
    {
15
        static readonly string host = "localhost";
15
        static readonly byte[] host = new byte[] { 127, 0, 0, 1};
16 16
        static readonly int port = 30010;
17 17

  
18 18
        public static void PrintEvent(Event theEvent)
rsb-cil/Rsb/Transport/Socket/BusClientConnection.cs
6 6
using Google.Protobuf;
7 7

  
8 8
using Rsb.Protocol;
9
using System.Net;
9 10

  
10 11
namespace Rsb.Transport.Socket
11 12
{
......
17 18
        private static readonly int MESSAGE_LENGTH_SIZE = 4;
18 19
        private static readonly int MESSAGE_VERSION_SIZE = 4;
19 20

  
20
        private String host;
21
        private int port;
21
        private IPEndPoint remoteEndPoint;
22 22
        private TcpClient client = null;
23 23
        private NetworkStream stream = null;
24 24

  
25
        public BusClientConnection(String host, int port)
25
        // legacy
26
        public BusClientConnection(byte[] ip, int port)
26 27
        {
27
            this.host = host;
28
            this.port = port;
28
            remoteEndPoint = new IPEndPoint(new IPAddress(ip), port);
29
        }
30

  
31
        public BusClientConnection(IPEndPoint remote)
32
        {
33
            remoteEndPoint = remote;
29 34
        }
30 35

  
31 36
        public void Activate()
......
33 38
            LOGGER.Debug("Activating");
34 39

  
35 40

  
36
            this.client = new TcpClient(host, port);
41
            this.client = new TcpClient(remoteEndPoint.AddressFamily);
42
            this.client.Connect(remoteEndPoint);
37 43
            this.client.NoDelay = true;
38 44
            this.stream = client.GetStream();
39 45

  
40
-