public void disconnect() { if (sockChan != null) { sockChan.close(); } sockChan = null; activeConnection = false; }
public bool connect(string hostname, int port) { if (sockChan == null) { sockChan = new SocketChannel(); } else if (sockChan.isConnected()) { disconnect(); } sockChan.connect(hostname, port); return(sockChan.isConnected()); }
public bool connect(string host, int port) { if (sockChan == null) { sockChan = new SocketChannel(); } else if (sockChan.isConnected()) { disconnect(); sockChan = new SocketChannel(); // force build of new socket connection } this.host = host; this.port = port; sockChan.connect(this.host, this.port); return(sockChan.isConnected()); }
virtual public bool connect(string hostname, int port) { // if ( sockChan == null ) // { sockChan = new SocketChannel(); // } // else if ( sockChan != null && sockChan.isConnected()) { // disconnect(); // disconnect old connection //} sockChan.connect(hostname, port); activeConnection = sockChan.isConnected(); if (activeConnection) // cache the connection info { this.host = hostname; this.port = port; } return(activeConnection); }