Jump to content

Java Exception - Socket is closed, reliable udp help

- - - - -

  • Please log in to reply
3 replies to this topic

#1
liamzebedee

liamzebedee

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
See here.

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java

Quote

[TABLE]
[TR]
[TD="class: votecell"][/TD]
[TD="class: postcell"] I'm currently using a Java implementation of the Reliable UDP protocol, found [here][1]. The project has absolutely no tutorials so I have found it really hard to identify problems.
I have set up a client and server. The server runs on localhost:1234 and the client runs on localhost:1235. The server is first established, and loops listening for connections.
I then have set it to send a packet to the server. When a packet is sent, the server calls handlePacket() -

DataInputStream i = new DataInputStream(client.getSocket().getInputStream());
            short packetID = i.readShort();
            i = null;
            switch(packetID){
                case 3:
                    Packeta packeta = new Packeta(client);
                break;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
I'm currently using a debugging with a small dummy class called Packeta. When the constructor is called, it reads from a stream and the logs to the console. However, always when constructing, it hangs for 10 seconds, before producing the error -

java.net.SocketException: Socket is closed ....
at lessur.engine.net.packets.Packeta.(Packeta.java:15)

The constructor for Packeta -

public Packeta(LessurConnectedNode c) {
        super((short)3, c);
        try {
            /*LINE 15*/ Logger.getLogger("adsfas").info("X was "+c.getSocket().getInputStream().read());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
It has something todo with the input streams. I don't know what is wrong, but from reading other threads, it might be todo with having multiple inputstreams. I'm lost on this, please help.

[/TD]
[/TR]
[/TABLE]
Okay, pretty simple. Pick one:

  • Server isn't running or has stopped running.
  • Server has closed its socket or never opened it.
  • LesserConnectedNode contains a bad reference to the Server's socket.


#3
liamzebedee

liamzebedee

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
The problem was, I was passing the server to the socket listener, before the socket was fully initialized. FIXED!

#4
liamzebedee

liamzebedee

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
Its happening again




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users