예제 #1
0
 protected virtual void OnStarted()
 {
     connection = DoConnect(SourceUri);
     if (connection == null)
     {
         DoStop(StopReason.ConnectionError);
     }
 }
예제 #2
0
 protected StreamConnection DoConnect(IPEndPoint endpoint)
 {
     try {
     client = new TcpClient();
     client.Connect(endpoint);
     remoteEndPoint = (IPEndPoint)client.Client.RemoteEndPoint;
     var stream = client.GetStream();
     var connection = new StreamConnection(stream, stream);
     connection.ReceiveTimeout = 10000;
     connection.SendTimeout    = 8000;
     Logger.Debug("Connected: {0}", endpoint);
     return connection;
       }
       catch (SocketException e) {
     Logger.Debug("Connection Failed: {0}", endpoint);
     Logger.Debug(e);
     return null;
       }
 }
예제 #3
0
 protected override void DoClose(StreamConnection connection)
 {
     Logger.Debug("closing connection");
       connection.Close();
       Logger.Debug("closing client");
       client.Close();
       Logger.Debug("closed");
       state = State.Disconnected;
 }
예제 #4
0
 protected override StreamConnection DoConnect(Uri source)
 {
     try {
     client = new TcpClient();
     if (source.HostNameType==UriHostNameType.IPv4 ||
     source.HostNameType==UriHostNameType.IPv6) {
       client.Connect(IPAddress.Parse(source.Host), source.Port);
     }
     else {
       client.Connect(source.DnsSafeHost, source.Port);
     }
     var stream = client.GetStream();
     var connection = new StreamConnection(stream, stream);
     connection.ReceiveTimeout = 10000;
     connection.SendTimeout    = 8000;
     return connection;
       }
       catch (SocketException e) {
     Logger.Error(e);
     return null;
       }
 }
예제 #5
0
 protected override void DoClose(StreamConnection connection)
 {
     connection.Close();
       client.Close();
       state = State.Disconnected;
 }
예제 #6
0
 protected override StreamConnection DoConnect(Uri source)
 {
     try {
     client = new TcpClient();
     client.Connect(source.DnsSafeHost, source.Port);
     var stream = client.GetStream();
     var connection = new StreamConnection(stream, stream);
     connection.ReceiveTimeout = 3000;
     connection.SendTimeout    = 3000;
     return connection;
       }
       catch (SocketException e) {
     Logger.Error(e);
     return null;
       }
 }
 protected virtual void OnStarted()
 {
     connection = DoConnect(SourceUri);
       if (connection==null) {
     DoStop(StopReason.ConnectionError);
       }
 }
 protected abstract void DoClose(StreamConnection connection);
예제 #9
0
 protected abstract void             DoClose(StreamConnection connection);
예제 #10
0
 protected override void DoClose(StreamConnection connection)
 {
     this.connection.Close();
       this.client.Close();
       Logger.Debug("Closed");
 }