< prev index next >

test/jdk/java/net/DatagramSocket/SendDatagramToBadAddress.java

Print this page
rev 59105 : imported patch corelibs


  30  *  to an invalid destination (on platforms that support it).
  31  */
  32 
  33 import java.net.*;
  34 import java.util.*;
  35 import java.io.InterruptedIOException;
  36 
  37 public class SendDatagramToBadAddress {
  38 
  39     static boolean debug = false;
  40 
  41     public static boolean OSsupportsFeature () {
  42         Properties p = System.getProperties ();
  43         String v;
  44         if (p.getProperty ("os.name").equals ("Windows 2000"))
  45             return (true);
  46         if (p.getProperty ("os.name").equals ("Linux"))
  47             return (true);
  48         if (p.getProperty ("os.name").startsWith ("Mac OS"))
  49             return (true);
  50         // Check for specific Solaris version from here
  51         v = p.getProperty ("os.arch");
  52         if (!v.equalsIgnoreCase ("sparc"))
  53             return (false);
  54         v = p.getProperty ("os.name");
  55         if (!v.equalsIgnoreCase ("Solaris") && !v.equalsIgnoreCase ("SunOS"))
  56             return (false);
  57         v = p.getProperty ("os.version");
  58         if (v.equals ("5.8") || v.equals ("8"))
  59             return (false);
  60         return (true);
  61     }
  62 
  63     static void print (String s) {
  64         if (debug)
  65             System.out.println (s);
  66     }
  67 
  68     class Server {
  69 
  70         DatagramSocket server;
  71         byte[] buf = new byte [128];
  72         DatagramPacket pack = new DatagramPacket (buf, buf.length);
  73 
  74         public Server (DatagramSocket s) {
  75             server = s;
  76         }
  77 
  78         public void receive (int loop, boolean expectError) throws Exception {
  79             for (int i=0; i<loop; i++) {
  80                 try {




  30  *  to an invalid destination (on platforms that support it).
  31  */
  32 
  33 import java.net.*;
  34 import java.util.*;
  35 import java.io.InterruptedIOException;
  36 
  37 public class SendDatagramToBadAddress {
  38 
  39     static boolean debug = false;
  40 
  41     public static boolean OSsupportsFeature () {
  42         Properties p = System.getProperties ();
  43         String v;
  44         if (p.getProperty ("os.name").equals ("Windows 2000"))
  45             return (true);
  46         if (p.getProperty ("os.name").equals ("Linux"))
  47             return (true);
  48         if (p.getProperty ("os.name").startsWith ("Mac OS"))
  49             return (true);
  50         return false;










  51     }
  52 
  53     static void print (String s) {
  54         if (debug)
  55             System.out.println (s);
  56     }
  57 
  58     class Server {
  59 
  60         DatagramSocket server;
  61         byte[] buf = new byte [128];
  62         DatagramPacket pack = new DatagramPacket (buf, buf.length);
  63 
  64         public Server (DatagramSocket s) {
  65             server = s;
  66         }
  67 
  68         public void receive (int loop, boolean expectError) throws Exception {
  69             for (int i=0; i<loop; i++) {
  70                 try {


< prev index next >