sockets - Android not getting past serverSocket.accept(); -


i trying open socket in android, code keeps sticking @ 1 sentence.

  private serversocket serversocket;   private socket clientsocket;   private printwriter out;   private bufferedreader in;    public void run(){     log.i("debugmessage", "serverthread received pulse. trying open socket now!");     try{       serversocket = new serversocket(25555);       log.i("debugmessage", "serversocket open, waiting clientsocket.");       clientsocket = serversocket.accept();       log.i("debugmessage", "serversocket , clientsocket both open! waiting in-/output!");        in = new bufferedreader(              new inputstreamreader(clientsocket.getinputstream()));       out = new printwriter(clientsocket.getoutputstream(), true);        string input = in.readline();       out.println("received: " + input);        in.close();       out.close();      } catch(exception e) {         log.i("debugmessage", "failed open socket!");     e.printstacktrace();     }   } 

at clientsocket = serversocket.accept(); keeps sticking. have seen question few other times, answers given totally different. here being said code, , here being said problem emulator. question is, problem emulator or code, , if code, how possible fix it?

by way, have added these lines androidmanifest.xml:

<uses-permission android:name="android.permission.internet" > </uses-permission> 

serversocket.accept() waits until device connects socket's port (25555 in case) on device's ip address. proceed , return socket when there new connection.

you'll find more information in docs.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -