Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beta JDK 1.1.2 port for FreeBSD



> I just uploaded a new port of Sun's JDK 1.1.2 for FreeBSD at:
> 
> "ftp://ftp.freebsd.org/pub/FreeBSD/incoming"
> 
> Right now, there are two files, but only one is the right one:
> 
> "jdk1.1.2-fbsd1.tgz.good"
> 
> This is a "beta" release for people on this list, it'll probably release
> another one in 2 weeks, after I get some initial comments on it.

It has multicast problems.

I get this when I run the attached test program:

pantzer@skalman ~/java/mcast >java MulticastServer 224.111.11.1 1234
Multicast Server listening on port:1234
java.net.SocketException: Inappropriate ioctl for device


The jdk1.1-kwhite port had the same problem, and the followig patch to 
src/freebsd/net/multicast.c fixed that in that port:

70c70
<   if (!IN_MULTICAST(mname.imr_multiaddr.s_addr)) {
---
>   if (!IN_MULTICAST(addrptr->address)) {
114c114
<   if (!IN_MULTICAST(mname.imr_multiaddr.s_addr)) {
---
>   if (!IN_MULTICAST(addrptr->address)) {


It was just a simple mater of changing byte order at the wrong place.
import java.io.*;
import java.net.*;
import java.util.*;

// Run this classes as:
// java_g MulticastServer 224.111.11.1 1234
// java_g MulticastClient 224.111.11.1 1234
// 
class MulticastServer {
    public static void main(String argv[]) {
	if (argv.length!=2) {
	    System.out.println("java MulticastServer <multicast_addr> <port#>");
	    return;
	}
	try {
	    int port = Integer.parseInt(argv[1]);
	    MulticastSocket s = new MulticastSocket(port);
	    // MulticastSocket s = new MulticastSocket();
	    System.out.print("Multicast Server listening on port:");
	    System.out.println(s.getLocalPort());
	    
	    // join the multicast group
	    s.joinGroup(InetAddress.getByName(argv[0]));
	    
	    byte buf[] = new byte[15];
	    DatagramPacket dp = new DatagramPacket(buf, buf.length);
	    s.receive(dp);
	    System.out.print("Received from inet address: "
			     + dp.getAddress().toString());
	    System.out.println(" port number: " + dp.getPort());
	    System.out.println("Packet of length: " + dp.getLength());
	    for (int i=0; i<dp.getLength(); ++i)  System.out.println(buf[i]);
	    s.leaveGroup(InetAddress.getByName(argv[0]));
	    s.close();
	} catch (Exception e) {
    		System.out.println(e);
	}
    }
}

class MulticastClient {
  public static void main(String argv[]) {
    if (argv.length!=2) {
      System.out.println("java MulticastClient <multicast_addr> <port#>");
      return;
    }
    try {
      int port = Integer.parseInt(argv[1]);
      InetAddress in = InetAddress.getByName(argv[0]);
      MulticastSocket s = new MulticastSocket();
      byte buf[] = new byte[10];
      for (int i=0; i<buf.length; ++i)
	buf[i] = (byte)i;
      int ttl = 10;
      DatagramPacket dp = dp = new DatagramPacket(buf,buf.length, in, port);
      s.send(dp, (byte)ttl);
      System.out.print("Sent from port: " + s.getLocalPort());
      System.out.println(" to: " + dp.getPort());
      s.close();
    } catch (Exception e) {
      System.err.println(e);
    }
  }
}