Thread View: borland.public.jbuilder.java.api
2 messages
2 total messages
Started by jinxiaojin
Fri, 30 Aug 2002 02:08
What is the wrong?
Author: jinxiaojin
Date: Fri, 30 Aug 2002 02:08
Date: Fri, 30 Aug 2002 02:08
38 lines
1948 bytes
1948 bytes
I wrote code like following,But when it run,it report:
java.net.SocketException: socket closed
at java.net.PlainDatagramSocketImpl.receive(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:392)
at test.TT.main(tt.java:27)
what is matter?
code is :
import java.io.*;
import java.net.*;
import java.util.*;
public class TT {
public static void main(String[] args) throws Exception{
DatagramSocket socket = new DatagramSocket();
socket.setSoTimeout(3000);
byte[] buf = new byte[256];
InetAddress address = InetAddress.getByName("150.100.100.101");
DatagramPacket packet = new DatagramPacket(buf,buf.length,address,1111);
socket.send(packet);
packet = new DatagramPacket(buf,buf.length);
try
{
socket.receive(packet);
}
catch(Exception ex)
{
ex.printStackTrace();
}
socket.close();
}
}
Re: What is the wrong?
Author: jinxiaojin
Date: Fri, 30 Aug 2002 02:18
Date: Fri, 30 Aug 2002 02:18
11 lines
1317 bytes
1317 bytes
Append:
This problem is found in my Windows computer.OS:Windows 2K pro + SP3.
The code can run successfully in Solaris.
java.io.InterruptedIOException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive(Native Method)
at java.net.PlainDatagramSocketImpl.receive(Compiled Code)
at java.net.DatagramSocket.receive(Compiled Code)
at TT.main(TT.java:18)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads