Cant communicate with server in java

Posted by cerq on Stack Overflow See other posts from Stack Overflow or by cerq
Published on 2012-03-24T13:57:57Z Indexed on 2012/03/25 23:29 UTC
Read the original article Hit count: 138

Filed under:

i m trying to write server to client program but i cant communicate with server in java. Below there is code block in my main.

    InetAddress addr = InetAddress.getLocalHost();
    ipAddress = "78.162.206.164";
    ServerSocket serverSocket = new ServerSocket(0);
    String randomStringForPlayerName = RandomStringGenerator.generateRandomString(); 

    baseForReqOpp += ipAddress + " " + serverSocket + " " + randomStringForPlayerName;
    Socket socket = new Socket(host,2050); 
    socket.setSoTimeout(100);

    in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    out = new PrintWriter(socket.getOutputStream());
    out.write(baseForReqOpp);
    out.flush();

    System.out.println(in.read());

i know there is no problem in server code and all the ports in communication are ok. But i cant read anything from server. What can be the problem?

© Stack Overflow or respective owner

Related posts about java