0

my program freezes when I put this code on a button,

but when I put it in the main it doesn't
what could be the problem?

protected void EstablishClient() {
    try {

        skt = new Socket("some.ip.of.me", 4444);  
        out = new PrintWriter(skt.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(skt.getInputStream()));
        txtRecvd.append("Received string: '" + "\n");

        String fromServer;
        while(!in.ready()){
        try{
            fromServer = in.readLine();
            txtRecvd.append("From Server: " + fromServer + "\n");
            }catch(IOException e){}
        }

Edited by Dani: Formatting fixed

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by aldeene
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.