java - socket.accept() does not execute -


i have code, wich download it.

import java.io.*; import java.net.*;  public class server {  public static void main(string argv[]) throws exception  {     string clientsentence;     string capitalizedsentence;     serversocket welcomesocket = new serversocket(6060);      while(true)     {        socket connectionsocket = welcomesocket.accept();        system.out.println("ssss");        bufferedreader infromclient =           new bufferedreader(new  inputstreamreader(connectionsocket.getinputstream()));        dataoutputstream outtoclient = new dataoutputstream(connectionsocket.getoutputstream());        clientsentence = infromclient.readline();        system.out.println("received: " + clientsentence);        capitalizedsentence = clientsentence.touppercase() + '\n';        outtoclient.writebytes(capitalizedsentence);     } } 

}

first ran when tried run runs not reach print statement :

system.out.println("ssss"); 

it stops on welcomesocket.accept();

even tried old server code used before did not run , stopped in same part , ran linux terminal.

it's working intended. .accept() function blocking function, meaning .accept() waits connection attempt , hold code there.

if make connection server, it'll move past point, print sss once, , after executing rest of while loop, stuck there again until make new connection.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -