gcj and UDP datagrams under freebsd
Mark Allman
mallman@grc.nasa.gov
Fri Apr 5 12:37:00 GMT 2002
Folks-
I wonder if anyone else has had a problem using UDP datagrams under
freebsd. I slurped the latest gcc stuff from CVS a couple of days
ago. I have two small programs that are attached below. They
compile using:
gcj -o snd --main=snd snd.java -pthread
gcj -o rcv --main=rcv rcv.java -pthread
just fine.
I run rcv -- which just sits there. But, when I run snd I get this:
% ./snd guns
assertion "!(addr & FLAGS)" failed: file "/home/mallman/GCC/libjava/java/lang/natObject.cc", line 772
Bus error (core dumped)
This is on a freebsd 4.4 machine.
I tried to same thing on my redhat 6.2 laptop (same version of gcc
that I grabbed from CVS a couple days ago) and it all worked as I
had envisioned. (The difference is the I don't have to use
"-pthread" when compiling on the linux box.)
Anyone have a guess about what is going on? Any help would be
appreciated.
Thanks!
allman
--
Mark Allman -- BBN/NASA GRC -- http://roland.grc.nasa.gov/~mallman/
=============================================================================
import java.net.*;
import java.io.*;
class rcv
{
public static void main (String [] args) throws SocketException,
IOException
{
DatagramSocket sock = new DatagramSocket (1234);
byte[] buffer = new byte[256];
DatagramPacket rpacket = new DatagramPacket (buffer,buffer.length);
DatagramPacket spacket;
String rcvd;
String msg;
sock.receive (rpacket);
rcvd = new String (rpacket.getData());
System.out.println ("RCVD: " + rcvd);
msg = new String ("from receiver");
buffer = msg.getBytes ();
spacket = new DatagramPacket (buffer, buffer.length,
rpacket.getAddress (),
rpacket.getPort ());
sock.send (spacket);
}
}
=============================================================================
import java.net.*;
import java.io.*;
class snd
{
public static void main (String [] args) throws SocketException,
IOException
{
DatagramSocket sock = new DatagramSocket ();
byte[] buffer = new byte[256];
String msg;
DatagramPacket spacket;
DatagramPacket rpacket;
InetAddress address;
String rcvd;
if (args.length != 1)
{
System.out.println("Usage: snd host");
return;
}
msg = new String ("from sender");
buffer = msg.getBytes ();
address = InetAddress.getByName (args[0]);
spacket = new DatagramPacket (buffer, buffer.length, address, 1234);
sock.send (spacket);
rpacket = new DatagramPacket (buffer, buffer.length);
sock.receive (rpacket);
rcvd = new String (rpacket.getData ());
System.out.println ("RCVD: " + rcvd);
}
}
=============================================================================
More information about the Java
mailing list