@Override public Socket connect(){
  Log.d(TAG,"Listening on [" + address.getHostAddress() + "]:"+ Integer.toString(port));
  final ServerSocket tempSocket;
  try {
    tempSocket=new ServerSocket(port,0,address);
  }
 catch (  IOException e) {
    reportError("Failed to create server socket: " + e.getMessage());
    return null;
  }
synchronized (rawSocketLock) {
    if (serverSocket != null) {
      Log.e(TAG,"Server rawSocket was already listening and new will be opened.");
    }
    serverSocket=tempSocket;
  }
  try {
    return tempSocket.accept();
  }
 catch (  IOException e) {
    reportError("Failed to receive connection: " + e.getMessage());
    return null;
  }
}

@ Override public Socket connect ( ) { Log . d ( TAG , "Listening on [" + address . getHostAddress ( ) + "]:" + Integer . toString ( port ) ) ; final ServerSocket tempSocket ; try { tempSocket = new ServerSocket ( port , 0 , address ) ; } catch ( IOException e ) { reportError ( "Failed to create server socket: " + e . getMessage ( ) ) ; return null ; } synchronized ( rawSocketLock ) { if ( serverSocket != null ) { Log . e ( TAG , "Server rawSocket was already listening and new will be opened." ) ; } serverSocket = tempSocket ; } try { return tempSocket . accept ( ) ; } catch ( IOException e ) { reportError ( "Failed to receive connection: " + e . getMessage ( ) ) ; return null ; } }
opens a listening socket and waits for a connection .
