How do I take to set up for network connect with Socket. I make the JList to press Go to run the post processing (like files). I feel about it and it is not work for me I try to figure out. Thanks.

public final static int port = #### ;(I will put any number)later.
    public final static String hostname = "";(i will put any name) later

 ev1GoButton.addActionListener(new networkListener());

 class networkListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            Socketnetwork(jListMain.getModel()); (it is not work) 
        }
    }

public void Socketnetwork(String name){
        try{
            Socket networks = new Socket(hostname,port);
            Writer out = new OutputStreamWriter(networks.getOutputStream(),"ASCII");
            BufferedReader in = new BufferedReader(new InputStreamReader(networks.getInputStream(),"ASCII"));
            String s;
            while ((s = in.readLine()) != null){
                if (s.indexOf('\n')>= 0){
                    s = s.replace('\n', ' ');
                    listModel.addElement(s);
                }
            }
        }catch(IOException e){
            JOptionPane.showMessageDialog(JFrame, "Warning, There is not connect!", "Warning dialog", JOptionPane.WARNING_MESSAGE);
        }
    }

Recommended Answers

All 2 Replies

Thank you so much i will read it.

Be a part of the DaniWeb community

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