-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.1
-
sparc
-
solaris_2.5
Name: mgC56079 Date: 09/05/97
The java.net.DatagramSocket.send(DatagramPacket) method does not send any
packets if it's data has zero length on Solaris 2.4, 2.5.x, no IOException
will be thrown.
Here is the test demonstrating the bug:
-------------------------------- Test.java -----------------------------
import java.net.*;
public class Test {
public static void main( String argv[] ) {
DatagramSocket soc=null;
DatagramSocket server = null;
DatagramPacket pac=null;
int port = 6768;
int server_port = 6869;
byte[] array = new byte[10];
byte array1[] = new byte[0];
// Try to create datagram socket...
try {
soc = new DatagramSocket();
} catch(Exception e)
{
System.out.println("Failed: Can not create DatagramSocket instance " + e);
System.exit(0);
}
// Try to create test server
try {
server = new DatagramSocket(server_port);
} catch(Exception e)
{
soc.close();
System.out.println("Failed: Can not create test server " + e + ": possible port " + server_port + " already in use");
System.exit(0);
}
pac = new DatagramPacket(array, array.length);
try {
server.setSoTimeout(1000);
soc.send(new DatagramPacket(array1, array1.length, InetAddress.getLocalHost(), server_port));
server.receive(pac);
server.setSoTimeout(0);
} catch(java.io.InterruptedIOException e)
{
soc.close();
server.close();
System.out.println("Failed: No packets received... Timeout expired.");
System.exit(0);
}
catch(Exception e)
{
soc.close();
server.close();
System.out.println("Failed: unexpected exception during send/receive data:" +e);
System.exit(0);
}
if(pac.getLength() == 0 )
{
soc.close();
server.close();
System.out.println("Test passed: OKAY");
System.exit(0);
}
soc.close();
server.close();
System.out.println("Failed: Send/received data mismatch");
System.exit(0);
}
}
---------------- Output from the test on Solaris 2.4, 2.5.x --------------
Failed: No packets received... Timeout expired.
--------------------------------------------------------------------------
---------------- Output from the test on Solaris 2.6, Win32 --------------
Test passed: OKAY
--------------------------------------------------------------------------
======================================================================