Example usage for android.net LocalServerSocket LocalServerSocket

List of usage examples for android.net LocalServerSocket LocalServerSocket

Introduction

In this page you can find the example usage for android.net LocalServerSocket LocalServerSocket.

Prototype

public LocalServerSocket(FileDescriptor fd) throws IOException 

Source Link

Document

Create a LocalServerSocket from a file descriptor that's already been created and bound.

Usage

From source file:com.facebook.stetho.server.LocalSocketHttpServer.java

@Nonnull
private static LocalServerSocket bindToSocket(String address) throws IOException {
    int retries = MAX_BIND_RETRIES;
    IOException firstException = null;
    do {/*from  w  w w.  ja va  2  s.  c  o  m*/
        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;
}