当前位置: 首页>>代码示例>>Java>>正文


Java LocalServerSocket类代码示例

本文整理汇总了Java中android.net.LocalServerSocket的典型用法代码示例。如果您正苦于以下问题:Java LocalServerSocket类的具体用法?Java LocalServerSocket怎么用?Java LocalServerSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalServerSocket类属于android.net包,在下文中一共展示了LocalServerSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSockets

import android.net.LocalServerSocket; //导入依赖的package包/类
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);
	}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:20,代码来源:MediaStream.java

示例2: Server

import android.net.LocalServerSocket; //导入依赖的package包/类
private Server(String packageName) {
    try {
        serverSocket = new LocalServerSocket(packageName);
        if (Log.isLoggable(Logging.LOG_TAG, Log.VERBOSE)) {
            Log.v(Logging.LOG_TAG, "Starting server socket listening for package " + packageName
                    + " on " + serverSocket.getLocalSocketAddress());
        }
    } catch (IOException e) {
        Log.e(Logging.LOG_TAG, "IO Error creating local socket at " + packageName, e);
        return;
    }
    startServer();

    if (Log.isLoggable(Logging.LOG_TAG, Log.VERBOSE)) {
        Log.v(Logging.LOG_TAG, "Started server for package " + packageName);
    }
}
 
开发者ID:typ0520,项目名称:fastdex,代码行数:18,代码来源:Server.java

示例3: bindToSocket

import android.net.LocalServerSocket; //导入依赖的package包/类
@Nonnull
private static LocalServerSocket bindToSocket(String address) throws IOException {
  int retries = MAX_BIND_RETRIES;
  IOException firstException = null;
  do {
    try {
      LogUtil.e("Trying to bind to @" + address);
      return new LocalServerSocket(address);
    } catch (BindException be) {
      LogUtil.e(be, "Binding error, sleep " + TIME_BETWEEN_BIND_RETRIES_MS + " ms...");
      if (firstException == null) {
        firstException = be;
      }
      Util.sleepUninterruptibly(TIME_BETWEEN_BIND_RETRIES_MS);
    }
  } while (retries-- > 0);

  throw firstException;
}
 
开发者ID:misakuo,项目名称:Dream-Catcher,代码行数:20,代码来源:LocalSocketServer.java

示例4: bindToSocket

import android.net.LocalServerSocket; //导入依赖的package包/类
@Nonnull
private static LocalServerSocket bindToSocket(String address) throws IOException {
  int retries = MAX_BIND_RETRIES;
  IOException firstException = null;
  do {
    try {
      if (LogUtil.isLoggable(Log.DEBUG)) {
        LogUtil.d("Trying to bind to @" + address);
      }
      return new LocalServerSocket(address);
    } catch (BindException be) {
      LogUtil.w(be, "Binding error, sleep " + TIME_BETWEEN_BIND_RETRIES_MS + " ms...");
      if (firstException == null) {
        firstException = be;
      }
      Util.sleepUninterruptibly(TIME_BETWEEN_BIND_RETRIES_MS);
    }
  } while (retries-- > 0);

  throw firstException;
}
 
开发者ID:Laisly,项目名称:weex,代码行数:22,代码来源:LocalSocketServer.java

示例5: init

import android.net.LocalServerSocket; //导入依赖的package包/类
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);
}
  }
 
开发者ID:cmusatyalab,项目名称:faceswap,代码行数:18,代码来源:CameraConnector.java

示例6: Server

import android.net.LocalServerSocket; //导入依赖的package包/类
/**
 * 私有构造方法
 * 主要是实例化一个 LocalServerSocket
 * 然后调用 startServer() 方法
 *
 * @param packageName packageName
 * @param application application
 */
private Server(@NonNull String packageName, @NonNull Application application) {
    mApplication = application;
    try {
        mServerSocket = new LocalServerSocket(packageName);
        if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
            Log.v(LOG_TAG, "Starting server socket listening for package " + packageName
                + " on " + mServerSocket.getLocalSocketAddress());
        }
    } catch (IOException e) {
        Log.e(LOG_TAG, "IO Error creating local socket at " + packageName, e);
        return;
    }
    startServer();

    if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
        Log.v(LOG_TAG, "Started server for package " + packageName);
    }
}
 
开发者ID:CaMnter,项目名称:AndroidLife,代码行数:27,代码来源:Server.java

示例7: create

import android.net.LocalServerSocket; //导入依赖的package包/类
@VisibleForTesting
static FileDescriptorFactory create(String address, String... cmd) throws IOException {
    // must be created before the process
    final LocalServerSocket socket = new LocalServerSocket(address);
    try {
        final Process shell = new ProcessBuilder(cmd)
                .redirectErrorStream(true)
                .start();

        final FileDescriptorFactory result = new FileDescriptorFactory(shell, socket);

        result.startServer();

        return result;
    } catch (Throwable t) {
        shut(socket);

        throw t;
    }
}
 
开发者ID:chdir,项目名称:fdshare,代码行数:21,代码来源:FileDescriptorFactory.java

示例8: Server

import android.net.LocalServerSocket; //导入依赖的package包/类
private Server(String packageName, Application application) {
    this.mApplication = application;
    try {
        this.mServerSocket = new LocalServerSocket(packageName);
        if (Log.isLoggable("InstantRun", 2)) {
            Log.v("InstantRun",
                  "Starting server socket listening for package " + packageName + " on " + this.mServerSocket.getLocalSocketAddress());
        }
    } catch (IOException e) {
        Log.e("InstantRun", "IO Error creating local socket at " + packageName, e);
        return;
    }
    startServer();
    if (Log.isLoggable("InstantRun", 2)) {
        Log.v("InstantRun", "Started server for package " + packageName);
    }
}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:18,代码来源:Server.java

示例9: createSockets

import android.net.LocalServerSocket; //导入依赖的package包/类
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(1000000);
		mReceiver.setSoTimeout(3000);
		mSender = mLss.accept();
		mSender.setSendBufferSize(1000000);
	}
 
开发者ID:Oo-Dev,项目名称:OoDroid2,代码行数:20,代码来源:MediaStream.java

示例10: createSockets

import android.net.LocalServerSocket; //导入依赖的package包/类
protected void createSockets() throws IOException {

		final String LOCAL_ADDR = "edu.ucsb.cs.capstone.letmypeoplecode.smartrover.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);
	}
 
开发者ID:sciencectn,项目名称:SmartRover,代码行数:20,代码来源:MediaStream.java

示例11: LocalSocketEventReporter

import android.net.LocalServerSocket; //导入依赖的package包/类
public LocalSocketEventReporter(String socketName, int timeoutInSec) {
    EventServer server1;
    try {
        LocalServerSocket socket = new LocalServerSocket(socketName);
        server1 = new EventServer(socket, timeoutInSec, TimeUnit.SECONDS);
    } catch (IOException e) {
        server1 = null;
        new RuntimeException("Unable to create server socket");
    }
    this.server = server1;
}
 
开发者ID:Microsoft,项目名称:AppCenter-Test-Espresso-Extensions,代码行数:12,代码来源:LocalSocketEventReporter.java

示例12: sendSync_will_return_false_if_no_one_listens

import android.net.LocalServerSocket; //导入依赖的package包/类
@Test
public void sendSync_will_return_false_if_no_one_listens() throws Exception {
    String socketName = "junitevent";
    LocalServerSocket socket = new LocalServerSocket(socketName);
    EventServer server = new EventServer(socket, 10, TimeUnit.MILLISECONDS);

    boolean b = server.sendSync(Event.create("id", EventType.started, "testName", "className", "1"));
    server.stop();

    assertFalse("sendSync without a listener should return false", b);
}
 
开发者ID:Microsoft,项目名称:AppCenter-Test-Espresso-Extensions,代码行数:12,代码来源:EventServerTest.java

示例13: sendSync_will_return_true_if_some_one_listens

import android.net.LocalServerSocket; //导入依赖的package包/类
@Test
public void sendSync_will_return_true_if_some_one_listens() throws Exception {
    String socketName = "junitevent2";
    LocalServerSocket socket = new LocalServerSocket(socketName);
    EventServer server = new EventServer(socket, 10, TimeUnit.SECONDS);
    TestEventClient client = new TestEventClient(socketName);

    boolean b = server.sendSync(Event.create("id", EventType.started, "testName", "className", "1"));
    server.stop();
    client.stop();

    assertTrue("sendSync with a listener should return true", b);
}
 
开发者ID:Microsoft,项目名称:AppCenter-Test-Espresso-Extensions,代码行数:14,代码来源:EventServerTest.java

示例14: LocalProxySocket

import android.net.LocalServerSocket; //导入依赖的package包/类
public LocalProxySocket(Socket original) throws TorException {
    super();
    try {
        // Prepare LocalSocket which will be used to trick the SSLSocket (or any other one)
        localSocketSend = new LocalSocket();
        // Local socket name
        String socketName = "local" + UUID.randomUUID();
        localServerSocket = new LocalServerSocket(socketName);
        localSocketSend.connect(new LocalSocketAddress(socketName));
        localSocketRecv = localServerSocket.accept();
        this.originalSocket = original;
        // Create 2 Threads which are taking care of the communication between the LocalSocket and the original Socket
        LocalProxyWorker lpw1 = new LocalProxyWorker(localSocketRecv.getInputStream(), originalSocket.getOutputStream(), "to");
        LocalProxyWorker lpw2 = new LocalProxyWorker(originalSocket.getInputStream(), localSocketRecv.getOutputStream(), "from");
        Thread t1 = new Thread(lpw1);
        Thread t2 = new Thread(lpw2);
        t1.start();
        t2.start();
        // Prepare this Socket to contain the FileDescriptor of the LocalSocket
        FileDescriptor fd = localSocketSend.getFileDescriptor();
        SocketImpl socketImpl = (SocketImpl) Class.forName("java.net.PlainSocketImpl").getConstructor(FileDescriptor.class).newInstance(fd);
        Field implField = this.getClass().getSuperclass().getDeclaredField("impl");
        implField.setAccessible(true);
        implField.set(this, socketImpl);
    } catch (Exception e) {
        LOG.debug("Got Exception while trying to create LocalProxySocket", e);
        throw new TorException("could not create LocalProxySocket", e);
    }
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:30,代码来源:LocalProxySocket.java

示例15: createSockets

import android.net.LocalServerSocket; //导入依赖的package包/类
protected void createSockets() throws IOException {

		if (sPipeApi == PIPE_API_LS) {
			
			final String LOCAL_ADDR = "com.galuu.ev3videocontrol.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]);
		}
	}
 
开发者ID:galme,项目名称:ROLF-EV3,代码行数:29,代码来源:MediaStream.java


注:本文中的android.net.LocalServerSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。