lpr-b:copyout
no way to compare when less than two revisions
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
— | lpr-b:copyout [23/11/2007 alle 13:56 (18 anni fa)] (versione attuale) – creata Marco Danelutto | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
+ | <code java> | ||
+ | package chatMulticast; | ||
+ | import java.io.BufferedReader; | ||
+ | import java.io.IOException; | ||
+ | import java.io.InputStreamReader; | ||
+ | import java.net.DatagramPacket; | ||
+ | import java.net.DatagramSocket; | ||
+ | import java.net.InetAddress; | ||
+ | import java.net.SocketException; | ||
+ | |||
+ | public class CopyOut extends Thread { | ||
+ | |||
+ | InetAddress chatAddress = null; | ||
+ | int chatPort = 0; | ||
+ | |||
+ | public CopyOut(InetAddress chat, int port) { | ||
+ | chatAddress = chat; | ||
+ | chatPort = port; | ||
+ | } | ||
+ | |||
+ | public void run() { | ||
+ | DatagramSocket ds = null; | ||
+ | try { | ||
+ | ds = new DatagramSocket(); | ||
+ | } catch (SocketException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | BufferedReader in | ||
+ | = new BufferedReader(new InputStreamReader(System.in)); | ||
+ | String line = null; | ||
+ | try { | ||
+ | line = in.readLine(); | ||
+ | } catch (IOException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | do { | ||
+ | DatagramPacket dp = new DatagramPacket(line.getBytes(), | ||
+ | dp.setAddress(chatAddress); | ||
+ | dp.setPort(chatPort); | ||
+ | try { | ||
+ | ds.send(dp); | ||
+ | } catch (IOException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | try { | ||
+ | line = in.readLine(); | ||
+ | } catch (IOException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | } while(line != null); | ||
+ | |||
+ | } | ||
+ | } | ||
+ | </ |
lpr-b/copyout.txt · Ultima modifica: 23/11/2007 alle 13:56 (18 anni fa) da Marco Danelutto