@Override protected void onSecured(LocalSocket socket) throws IOException { LeakyBufferedInputStream leakyIn = new LeakyBufferedInputStream( socket.getInputStream(), SENSING_BUFFER_SIZE); if (mHandlers.isEmpty()) { throw new IllegalStateException("No handlers added"); } for (int i = 0, N = mHandlers.size(); i < N; i++) { HandlerInfo handlerInfo = mHandlers.get(i); leakyIn.mark(SENSING_BUFFER_SIZE); boolean matches = handlerInfo.magicMatcher.matches(leakyIn); leakyIn.reset(); if (matches) { SocketLike socketLike = new SocketLike(socket, leakyIn); handlerInfo.handler.onAccepted(socketLike); return; } } throw new IOException("No matching handler, firstByte=" + leakyIn.read()); }
@Override public int receive(byte[] packet) throws IOException { int r = localSocket.getInputStream().read(packet); if (GnirehtetService.VERBOSE) { Log.d(TAG, "Receiving..." + Binary.toString(packet, r)); } return r; }
@Override public void run() { try { DataInputStream input = new DataInputStream(socket.getInputStream()); DataOutputStream output = new DataOutputStream(socket.getOutputStream()); try { handle(input, output); } finally { try { input.close(); } catch (IOException ignore) { } try { output.close(); } catch (IOException ignore) { } } } catch (IOException e) { if (Log.isLoggable(Logging.LOG_TAG, Log.VERBOSE)) { Log.v(Logging.LOG_TAG, "Fatal error receiving messages", e); } } }
public void connect() throws IOException { localSocket.connect(new LocalSocketAddress(LOCAL_ABSTRACT_NAME)); readClientId(localSocket.getInputStream()); }
/** * @throws IOException */ @Override public InputStream getInputStream() throws IOException { return mLocalSocket.getInputStream(); }
@Override public InputStream getInputStream() throws IOException { return socket.getInputStream(); }
super.run(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); while (true) { String line;
@Override public void run() { try { socketHandler.handle(socket.getInputStream(), socket.getOutputStream()); } catch (IOException e) { Log.e(LOG_TAG, "Worker thread error", e); } finally { try { socket.close(); } catch (IOException e) { Log.w(LOG_TAG, "Unable to close socket"); } } } }
OutputStream os = null; try { is = s.getInputStream(); } catch (IOException ex) {
oos.flush(); ois = new ObjectInputStream(client.getInputStream()); Object obj = ois.readObject();
@Override protected void onSecured(LocalSocket socket) throws IOException { LeakyBufferedInputStream leakyIn = new LeakyBufferedInputStream( socket.getInputStream(), SENSING_BUFFER_SIZE); if (mHandlers.isEmpty()) { throw new IllegalStateException("No handlers added"); } for (int i = 0, N = mHandlers.size(); i < N; i++) { HandlerInfo handlerInfo = mHandlers.get(i); leakyIn.mark(SENSING_BUFFER_SIZE); boolean matches = handlerInfo.magicMatcher.matches(leakyIn); leakyIn.reset(); if (matches) { LogUtil.d("Matches!" + handlerInfo.handler.getClass().getSimpleName()); SocketLike socketLike = new SocketLike(socket, leakyIn); handlerInfo.handler.onAccepted(socketLike); return; } } throw new IOException("No matching handler, firstByte=" + leakyIn.read()); }
InputStream instream = mSocket.getInputStream();
@Test public void testGetInputStream() throws Exception { InputStream is = mock(InputStream.class); when(mockSocket.getInputStream()).thenReturn(is); assertSame(is, domainSocket.getInputStream()); }
while (!isInterrupted()) { Wire.Envelope envelope = Wire.Envelope.parseDelimitedFrom(clientSocket.getInputStream());
// Create a MediaRecorder MediaRecorder mr = new MediaRecorder(); // (Initialize mr as usual) // Create a LocalServerSocket LocalServerSocket lss = new LocalServerSocket("foobar"); // Connect both end of this socket LocalSocket sender = lss.accept(); LocalSocket receiver = new LocalSocket(); receiver.connect(new LocalSocketAddress("foobar")); // Set the output of the MediaRecorder to the sender socket file descriptor mr.setOutputFile(sender.getFileDescriptor()); // Start the video recording: mr.start(); // Launch a background thread that will loop, // reading from the receiver socket, // and creating a RTP packet out of read data. RtpSocket rtpSocket = new RtpSocket(); InputStream in = receiver.getInputStream(); while(true) { fis.read(buffer, ...); // Here some data manipulation on the received buffer ... RtpPacket rtp = new RtpPacket(buffer, ...); rtpSocket.send(rtpPacket); }
String inputSocketAdress = intent.getStringExtra(SOCKET_INPUT_EXTRA); inputSocket.connect(new LocalSocketAddress(inputSocketAdress)); ((WithInput) resultWriter).setInput(inputSocket.getInputStream()); resultWriter.writeResult(writer);
mPacketizer.setInputStream(mReceiver.getInputStream()); mPacketizer.start(); mStreaming = true;
try { is = mReceiver.getInputStream(); } catch (IOException e) { stop();
try { is = mReceiver.getInputStream(); } catch (IOException e) { stop();
out = receiver.getInputStream(); } catch (IOException e) {