Exemple #1
0
 public TcpTalk(TcpClient client)
 {
     var ipAddress = ((IPEndPoint)client.Client.RemoteEndPoint).Address;
     var port = ((IPEndPoint)client.Client.RemoteEndPoint).Port;
     Destination = new TcpAddress(ipAddress, port);
     _client = client;
     _client.LingerState.Enabled = false;
     ReadFromStream();
 }
Exemple #2
0
        public TcpTalk(int port, TcpAddress destination)
        {
            Destination = destination;

            var ipLocalEndPoint = new IPEndPoint(GetIpAddress(), port);
            _client = new TcpClient(ipLocalEndPoint);
            _client.LingerState.Enabled = false;
            _client.Connect(destination.Host, destination.Port);
            ReadFromStream();
        }
Exemple #3
0
 private TcpTalk GetTalker(string connectionId, TcpAddress destination)
 {
     lock (_talkers)
     {
         TcpTalk talker;
         if (!_talkers.TryGetValue(connectionId, out talker))
         {
             talker = new TcpTalk(_port, destination);
             talker.HandleMessage(HandleMessage);
             _talkers[connectionId] = talker;
         }
         return talker;
     }
 }