harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Lee <littlee1...@gmail.com>
Subject Problems about socket hang methods
Date Thu, 11 Jun 2009 05:28:16 GMT
Given the test case [1], on linux,  RI will throw a SocketException but
harmony is hanging forever. The problem is from such situation:
1. A fd is used by a slow api, such as read for example.
2. Another thread close the same fd.

Our api will hang forever, because we do not have any way to inform the slow
api that the fd is closed.
1. Do we have api to know this?
2. Is signal a way to solve this? If yes, more concern about this:
    i. Can we use all the real-time signals? For drlvm, I know it uses
SIGUSR2 for gc, any other signal it will use? For vme, no signal it uses, am
I right?
    ii. If we use signal, we need to know the exact process id which is
using the same fd, or we will miss-fire other process to close the read for

Any other ideas about this?

public class SocketHangTest {
    private Socket socket;
    private ServerSocket server;
    private SocketAddress localAddress;

    public SocketHangTest() {}

    public void hang() throws Exception{
        server = new ServerSocket(0);
        int port = server.getLocalPort();
        socket = new Socket();
        localAddress = new InetSocketAddress("", port);

        new Thread() {
            public void run() {
                try {
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                try {
                    System.out.println("Connecting to local host .....");
                    socket.connect(localAddress, 5000);
                    System.out.println("Reading ....");
                    InputStream input = socket.getInputStream();
                } catch (IOException e) {
                    // TODO Auto-generated catch block

        System.out.println("After accepting ...");

    public static void main(String[] args) throws Exception{
        SocketHangTest test = new SocketHangTest();

Yours sincerely,
Charles Lee

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message