/// <exception cref="System.IO.IOException"/> internal NioInetPeer(Socket socket) { this.socket = socket; this.@in = new SocketInputStream(socket.GetChannel(), 0); this.@out = new SocketOutputStream(socket.GetChannel(), 0); this.isLocal = socket.GetInetAddress().Equals(socket.GetLocalAddress()); }
////////////////////////////////////////////////////////////////////////// #region Thread For Connect public void ConnectThread() { m_connectStatus = ConnectStatus.CONNECTING; while (true) { m_Socket.close(); Console.WriteLine("connect:" + m_strServerAddr); m_strConnectResult = m_Socket.connect(m_strServerAddr, m_nServerPort); if (m_strConnectResult.Length == 0 && m_Socket.IsValid) { m_SocketInputStream = new SocketInputStream(m_Socket); m_SocketOutputStream = new SocketOutputStream(m_Socket); m_connectStatus = ConnectStatus.CONNECTED; break; } else { LogModule.WarningLog(m_strConnectResult); } m_Socket.close(); Thread.Sleep(m_nConnectSleep); m_connectStatus = ConnectStatus.DISCONNECTED; break; } m_bConnectFinish = true; }
private DicomConnection(Socket socket, CancellationToken cancellationToken) { Socket = socket; SocketInputStream = new SocketInputStream(socket, cancellationToken); SocketOutputStream = new SocketOutputStream(socket, cancellationToken); Input = new BufferedStreamReader(SocketInputStream); Output = new BufferedStreamWriter(SocketOutputStream); }
public void Dispose() { SocketOutputStream.Dispose(); SocketInputStream.Dispose(); Socket.Dispose(); }