private int connectToServer(boolean channel) throws IOException {
InetSocketAddress isa = new InetSocketAddress(
InetAddress.getByName(server), port);
// Connect
if (channel) {
sc = new SSLSocketChannel();
sc.configureBlocking(false);
sc.connect(isa);
while (!sc.finishConnect()) {
try {
Thread.sleep(20);