Java Code Examples for android.net.LocalSocket#connect()
The following examples show how to use
android.net.LocalSocket#connect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecoverySystemService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private LocalSocket connectService() { LocalSocket socket = new LocalSocket(); boolean done = false; // The uncrypt socket will be created by init upon receiving the // service request. It may not be ready by this point. So we will // keep retrying until success or reaching timeout. for (int retry = 0; retry < SOCKET_CONNECTION_MAX_RETRY; retry++) { try { socket.connect(new LocalSocketAddress(UNCRYPT_SOCKET, LocalSocketAddress.Namespace.RESERVED)); done = true; break; } catch (IOException ignored) { try { Thread.sleep(1000); } catch (InterruptedException e) { Slog.w(TAG, "Interrupted:", e); } } } if (!done) { Slog.e(TAG, "Timed out connecting to uncrypt socket"); return null; } return socket; }
Example 2
Source File: CameraConnector.java From faceswap with Apache License 2.0 | 6 votes |
public void init() { try { localLoop = new LocalServerSocket("videoserver"); localReceiver = new LocalSocket(); localReceiver.connect(localLoop.getLocalSocketAddress()); localReceiver.setReceiveBufferSize(LOCAL_BUFF_SIZE); localReceiver.setSendBufferSize(LOCAL_BUFF_SIZE); localSender = localLoop.accept(); localSender.setReceiveBufferSize(LOCAL_BUFF_SIZE); localSender.setSendBufferSize(LOCAL_BUFF_SIZE); Log.d(LOG_TAG, "Done: init()"); }catch(IOException e) { Log.e(LOG_TAG, "Error in initializing local socket: " + e); } }
Example 3
Source File: MediaStream.java From spydroid-ipcamera with GNU General Public License v3.0 | 6 votes |
protected void createSockets() throws IOException { final String LOCAL_ADDR = "net.majorkernelpanic.streaming-"; for (int i=0;i<10;i++) { try { mSocketId = new Random().nextInt(); mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId); break; } catch (IOException e1) {} } mReceiver = new LocalSocket(); mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId)); mReceiver.setReceiveBufferSize(500000); mReceiver.setSoTimeout(3000); mSender = mLss.accept(); mSender.setSendBufferSize(500000); }
Example 4
Source File: ProcessList.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static boolean openLmkdSocket() { try { sLmkdSocket = new LocalSocket(LocalSocket.SOCKET_SEQPACKET); sLmkdSocket.connect( new LocalSocketAddress("lmkd", LocalSocketAddress.Namespace.RESERVED)); sLmkdOutputStream = sLmkdSocket.getOutputStream(); } catch (IOException ex) { Slog.w(TAG, "lowmemorykiller daemon socket open failed"); sLmkdSocket = null; return false; } return true; }
Example 5
Source File: MediaStream.java From libstreaming with Apache License 2.0 | 5 votes |
protected void createSockets() throws IOException { if (sPipeApi == PIPE_API_LS) { final String LOCAL_ADDR = "net.majorkernelpanic.streaming-"; for (int i=0;i<10;i++) { try { mSocketId = new Random().nextInt(); mLss = new LocalServerSocket(LOCAL_ADDR+mSocketId); break; } catch (IOException e1) {} } mReceiver = new LocalSocket(); mReceiver.connect( new LocalSocketAddress(LOCAL_ADDR+mSocketId)); mReceiver.setReceiveBufferSize(500000); mReceiver.setSoTimeout(3000); mSender = mLss.accept(); mSender.setSendBufferSize(500000); } else { Log.e(TAG, "parcelFileDescriptors createPipe version = Lollipop"); mParcelFileDescriptors = ParcelFileDescriptor.createPipe(); mParcelRead = new ParcelFileDescriptor(mParcelFileDescriptors[0]); mParcelWrite = new ParcelFileDescriptor(mParcelFileDescriptors[1]); } }
Example 6
Source File: LocalSocketUtil.java From JsDroidCmd with Mozilla Public License 2.0 | 4 votes |
public LocalSocketUtil(String name) throws UnknownHostException, IOException { socket = new LocalSocket(); socket.connect(new LocalSocketAddress(name)); }