//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void openChannel() throws java.io.IOException internal virtual void openChannel() { if (socketChannel == null) { socketChannel = SocketChannel.open(); // Use a non-blocking channel as we are polling for data socketChannel.configureBlocking(false); // Connect has no timeout socketChannel.socket().SoTimeout = 0; } }
/// <summary> /// Attempts to connect to the debug bridge server. </summary> /// <returns> a connect socket if success, null otherwise </returns> private SocketChannel openAdbConnection() { Log.d("DeviceMonitor", "Connecting to adb for Device List Monitoring..."); SocketChannel adbChannel = null; try { adbChannel = SocketChannel.open(AndroidDebugBridge.socketAddress); adbChannel.socket().NoDelay = true; } catch (IOException) { } return(adbChannel); }
/// <summary> /// Create and connect a new pass-through socket, from the host to a port on /// the device. /// </summary> /// <param name="adbSockAddr"> </param> /// <param name="device"> the device to connect to. Can be null in which case the connection will be /// to the first available device. </param> /// <param name="devicePort"> the port we're opening </param> /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception> /// <exception cref="IOException"> in case of I/O error on the connection. </exception> /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.nio.channels.SocketChannel open(java.net.InetSocketAddress adbSockAddr, Device device, int devicePort) throws java.io.IOException, TimeoutException, AdbCommandRejectedException public static SocketChannel open(EndPoint adbSockAddr, Device device, int devicePort) { SocketChannel adbChan = SocketChannel.open(adbSockAddr); try { adbChan.socket().NoDelay = true; adbChan.configureBlocking(false); // if the device is not -1, then we first tell adb we're looking to // talk to a specific device setDevice(adbChan, device); var req = createAdbForwardRequest(null, devicePort); // Log.hexDump(req); write(adbChan, req); AdbResponse resp = readAdbResponse(adbChan, false); if (resp.okay == false) { throw new AdbCommandRejectedException(resp.message); } adbChan.configureBlocking(true); } catch (TimeoutException e) { adbChan.close(); throw e; } catch (IOException e) { adbChan.close(); throw e; } return(adbChan); }