use of android.net.LocalSocket in project stetho by facebook.
the class LocalSocketServer method listenOnAddress.
private void listenOnAddress(String address) throws IOException {
mServerSocket = bindToSocket(address);
LogUtil.i("Listening on @" + address);
while (!Thread.interrupted()) {
try {
// Use previously accepted socket the first time around, otherwise wait to
// accept another.
LocalSocket socket = mServerSocket.accept();
// Start worker thread
Thread t = new WorkerThread(socket, mSocketHandler);
t.setName(WORKER_THREAD_NAME_PREFIX + "-" + mFriendlyName + "-" + mThreadId.incrementAndGet());
t.setDaemon(true);
t.start();
} catch (SocketException se) {
// ignore exception if interrupting the thread
if (Thread.interrupted()) {
break;
}
LogUtil.w(se, "I/O error");
} catch (InterruptedIOException ex) {
break;
} catch (IOException e) {
LogUtil.w(e, "I/O error initialising connection thread");
break;
}
}
LogUtil.i("Server shutdown on @" + address);
}
use of android.net.LocalSocket in project libstreaming by fyhertz.
the class MediaStream method createSockets.
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]);
}
}
Aggregations