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("", 4444);  
        out = new PrintWriter(skt.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(skt.getInputStream()));
        txtRecvd.append("Received string: '" + "\n");

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

i figured it out. thread closed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.