Code example for Socket

Methods: setKeepAlivesetSoTimeout

0
		if (scheme != null && scheme.equals("ws")) {
			if (port == -1) {
				port = 80;
			} 
			try { 
				socket = new Socket(host, port);
				socket.setKeepAlive(true);
				socket.setSoTimeout(0);
			} catch (UnknownHostException uhe) {
				uhe.printStackTrace();
				throw new WebSocketException("unknown host: " + host, uhe);
			} catch (IOException ioe) {
				ioe.printStackTrace();
				throw new WebSocketException("error while creating socket to " 
						+ url, ioe);
			} 
		} else if (scheme != null && scheme.equals("wss")) {
			if (port == -1) {
				port = 443;
			} 
Stop searching for code, let great code find you!  Add Codota to your java IDE