/* * Intiate and open a connection to a remote node. * * @exception C#.io.IOException if it was not possible to connect to the peer. * @exception OtpAuthException if handshake resulted in an authentication error. */ protected internal AbstractConnection(OtpLocalNode self, OtpPeer other) : this(self, other, self.cookie()) { }
/* * Accept an incoming connection from a remote node. Used by {@link * OtpSelf#accept() OtpSelf.accept()} to create a connection * based on data received when handshaking with the peer node, when * the remote node is the connection intitiator. * * @exception C#.io.IOException if it was not possible to connect to the peer. * @exception OtpAuthException if handshake resulted in an authentication error */ protected internal AbstractConnection(OtpLocalNode self, System.Net.Sockets.TcpClient s) { this.self = self; this.peer = new OtpPeer(); this.socket = s; this.auth_cookie = self.cookie(); this.socket.NoDelay = true; // Use keepalive timer this.socket.Client.SetSocketOption( System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.KeepAlive, true); // Close socket gracefully this.socket.Client.SetSocketOption( System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.DontLinger, true); //this.socket.ReceiveTimeout = 5000; if (traceLevel >= OtpTrace.Type.handshakeThreshold) { OtpTrace.TraceEvent("<- ACCEPT FROM " + System.Net.IPAddress.Parse(s.Client.RemoteEndPoint.ToString()).ToString() + ":" + (s.Client.RemoteEndPoint as System.Net.IPEndPoint).Port.ToString()); } // get his info recvName(this.peer); // now find highest common dist value if ((peer._proto != self._proto) || (self._distHigh < peer._distLow) || (self._distLow > peer._distHigh)) { close(); throw new System.IO.IOException("No common protocol found - cannot accept connection"); } // highest common version: min(peer.distHigh, self.distHigh) peer.distChoose = (peer._distHigh > self._distHigh?self._distHigh:peer._distHigh); doAccept(); this.name = peer.node(); }