libcutils/mq.c
void masterPeerInitialize(BytesListener* bytesListener, 
        DeathListener* deathListener) {
    // Create and bind socket.
    int listenerSocket = socket(AF_LOCAL, SOCK_STREAM, 0);
    if (listenerSocket == -1) {
        LOG_ALWAYS_FATAL("socket() error: %s", strerror(errno));
    }
    unlink(MASTER_PATH);
    int result = bind(listenerSocket, (SocketAddress*) getMasterAddress(), 
            sizeof(UnixAddress));
    if (result == -1) {
        LOG_ALWAYS_FATAL("bind() error: %s", strerror(errno));
    }

    LOGD("Listener socket: %d",  listenerSocket);   
    
    // Queue up to 16 connections.
    result = listen(listenerSocket, 16);
    if (result != 0) {
        LOG_ALWAYS_FATAL("listen() error: %s", strerror(errno));
    }

    // Make socket non-blocking.
    setNonBlocking(listenerSocket);

    // Create the peer for this process. Fail if we already have one.
    if (localPeer != NULL) {
        LOG_ALWAYS_FATAL("Peer is already initialized.");
    }
    localPeer = peerCreate();
    if (localPeer == NULL) {
        LOG_ALWAYS_FATAL("malloc() failed.");
    }
    localPeer->master = true;
    localPeer->onBytes = bytesListener;
    localPeer->onDeath = deathListener;
    
    // Make listener socket selectable.
    SelectableFd* listenerFd = selectorAdd(localPeer->selector, listenerSocket);
    if (listenerFd == NULL) {
        LOG_ALWAYS_FATAL("malloc() error.");
    }
    listenerFd->data = localPeer;
    listenerFd->onReadable = &masterAcceptConnection;
}
/**
 * Starts the master peer. The master peer differs from other peers in that
 * it is responsible for connecting the other peers. You can only have one
 * master peer.
 *
 * Goes into an I/O loop and does not return.
 */
Starts the master peer. The master peer differs from other peers in that
it is responsible for connecting the other peers. You can only have one
master peer.

Goes into an I/O loop and does not return.
Starts the master peer . The master peer differs from other peers in that it is responsible for connecting the other peers . You can only have one master peer . Goes into an I / O loop and does not return .
void masterPeerInitialize(BytesListener* bytesListener, 
        DeathListener* deathListener) {
    int listenerSocket = socket(AF_LOCAL, SOCK_STREAM, 0);
    if (listenerSocket == -1) {
        LOG_ALWAYS_FATAL("socket() error: %s", strerror(errno));
    }
    unlink(MASTER_PATH);
    int result = bind(listenerSocket, (SocketAddress*) getMasterAddress(), 
            sizeof(UnixAddress));
    if (result == -1) {
        LOG_ALWAYS_FATAL("bind() error: %s", strerror(errno));
    }
    LOGD("Listener socket: %d",  listenerSocket);   
    result = listen(listenerSocket, 16);
    if (result != 0) {
        LOG_ALWAYS_FATAL("listen() error: %s", strerror(errno));
    }
    setNonBlocking(listenerSocket);
    if (localPeer != NULL) {
        LOG_ALWAYS_FATAL("Peer is already initialized.");
    }
    localPeer = peerCreate();
    if (localPeer == NULL) {
        LOG_ALWAYS_FATAL("malloc() failed.");
    }
    localPeer->master = true;
    localPeer->onBytes = bytesListener;
    localPeer->onDeath = deathListener;
    SelectableFd* listenerFd = selectorAdd(localPeer->selector, listenerSocket);
    if (listenerFd == NULL) {
        LOG_ALWAYS_FATAL("malloc() error.");
    }
    listenerFd->data = localPeer;
    listenerFd->onReadable = &masterAcceptConnection;
}
void masterPeerInitialize ( BytesListener * bytesListener , DeathListener * deathListener ) { int listenerSocket = socket ( AF_LOCAL , SOCK_STREAM , 0 ) ; if ( listenerSocket == -1 ) { LOG_ALWAYS_FATAL ( " " , strerror ( errno ) ) ; } unlink ( MASTER_PATH ) ; int result = bind ( listenerSocket , ( SocketAddress * ) getMasterAddress ( ) , sizeof ( UnixAddress ) ) ; if ( result == -1 ) { LOG_ALWAYS_FATAL ( " " , strerror ( errno ) ) ; } LOGD ( " " , listenerSocket ) ; result = listen ( listenerSocket , 16 ) ; if ( result != 0 ) { LOG_ALWAYS_FATAL ( " " , strerror ( errno ) ) ; } setNonBlocking ( listenerSocket ) ; if ( localPeer != NULL ) { LOG_ALWAYS_FATAL ( " " ) ; } localPeer = peerCreate ( ) ; if ( localPeer == NULL ) { LOG_ALWAYS_FATAL ( " " ) ; } localPeer -> master = true ; localPeer -> onBytes = bytesListener ; localPeer -> onDeath = deathListener ; SelectableFd * listenerFd = selectorAdd ( localPeer -> selector , listenerSocket ) ; if ( listenerFd == NULL ) { LOG_ALWAYS_FATAL ( " " ) ; } listenerFd -> data = localPeer ; listenerFd -> onReadable = & masterAcceptConnection ; }
Starts the master peer.
Starts the master peer .
// Create and bind socket. // Queue up to 16 connections. // Make socket non-blocking. // Create the peer for this process. Fail if we already have one. // Make listener socket selectable.