Monday, February 8, 2010

Window Shortwave Antenna

The Stream Network Application

SERVER

import java.io. *;
    import java.net .*;
  • public class Server {String [] suggestions = {"Learn more" ;, 'It's better that you leave the house "," Dai Gi,
  • "Come on!", "Think of health", "It's a little 'de casino"};
  • public void go () {&
# 160; try {
    s1 = new ServerSocket ServerSocket (4242), / / \u200b\u200bI create a listening port
  • while (true) {/ / if someone asks to enter do I create a direct connection between server and client
  • & # 160; s1.accept Socket socket = ( ), / / \u200b\u200bthe socket is a socket
  • / / transmission data to the client:
  • PrintWriter write = new PrintWriter (presa.getOutputStream ());// class that sends the data to the virtual link
  • & # 160; getSuggerimenti String s = ();
  • & # 160; scrivi.println (s) / / send the string in the channel # s &
160; scrivi.close ();

& # 160; System.out.println (s )

}

        }

        catch(IOException ex){

            ex.printStackTrace();         }

    } return tips [r];

;

} public static void main (String args []) {

; Server serv = new Server ();
serv.go ();}

}





CLIENT

import java.io. *;
import java. net .*;
import javax.swing .*;
import java.awt .*;
import java.awt.event .*;
public class Client2
{JFrame f1 = new JFrame ("Client");
/ / JButton b = new JButton ();
a1 = new JTextArea JTextArea ();
/ / JLabel l1=new JLabel();

    public void go(){

        try{
            f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f1.setSize(500,500);
            f1.add(a1);
            f1.setVisible(true);
            //collegamento al server(ip,porta)
            for(int i=0;i<1;i++){
            Socket s = new Socket ("192.168.3.25", 4242);
InputStreamReader r = new InputStreamReader (s.getInputStream ());
BufferedReader reader = new BufferedReader (r);

/ / Statement to read from the server

& # 160; reader.readLine String tip = ();

& # 160; System.out.println ("Hint:" + hint);

; reader.close ();

; a1.setText (hint);

& # 160;}

} catch (IOException ex) {&

# 160; ex.printStackTrace ();}

}
public void window () {}


public static void main (String args []) {c = new
Client2 Client2 ();
c.go ();}

}



0 comments:

Post a Comment