lpr-b:copyin
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:copyin [23/11/2007 alle 13:55 (18 anni fa)] (versione attuale) – creata Marco Danelutto | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| + | <code java> | ||
| + | package chatMulticast; | ||
| + | import java.io.IOException; | ||
| + | import java.net.DatagramPacket; | ||
| + | import java.net.InetAddress; | ||
| + | import java.net.MulticastSocket; | ||
| + | |||
| + | public class CopyIn extends Thread { | ||
| + | |||
| + | int chatPort = 0; | ||
| + | InetAddress chatAddress = null; | ||
| + | |||
| + | final int MAXBUF = 1024; | ||
| + | |||
| + | public | ||
| + | chatPort = port; | ||
| + | chatAddress = ia; | ||
| + | } | ||
| + | |||
| + | public void run() { | ||
| + | MulticastSocket ds = null; | ||
| + | try { | ||
| + | ds = new MulticastSocket(chatPort); | ||
| + | } catch (IOException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | try { | ||
| + | ds.joinGroup(chatAddress); | ||
| + | } catch (IOException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | DatagramPacket dp = null; | ||
| + | while (true) { | ||
| + | try { | ||
| + | dp = new DatagramPacket(new byte[MAXBUF], | ||
| + | ds.receive(dp); | ||
| + | } catch (IOException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | String line = new String(dp.getData()); | ||
| + | System.out.println(" | ||
| + | } | ||
| + | } | ||
| + | |||
| + | } | ||
| + | </ | ||
lpr-b/copyin.txt · Ultima modifica: 23/11/2007 alle 13:55 (18 anni fa) da Marco Danelutto
