Interface NetworkApplication

All Superinterfaces:
Runnable
All Known Subinterfaces:
NetClientManager, NetServer
All Known Implementing Classes:
DTLSClientManager, DTLSServer, PlainTCPClientManager, PlainTCPServer, PlainUDPClientManager, PlainUDPServer, TCPClientManager, TCPServer, TLSClientManager, TLSServer, UDPClientManager, UDPServer

public interface NetworkApplication extends Runnable
Represents any networking application (for example, a client or server).
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    void
    Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call to start() to return.
    void
    Initializes this application.
    default void
    run()
    Method which implements the Runnable.run() function.
    void
    Runs the main loop of this instance.
  • Method Details Link icon

    • init Link icon

      void init() throws IOException
      Initializes this application.
      Throws:
      IOException - If an IO error occurs during initialization
    • close Link icon

      void close() throws IOException
      Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call to start() to return.
      Throws:
      IOException - If an IO error occurs
    • start Link icon

      void start() throws IOException
      Runs the main loop of this instance. This loop processes incoming or outgoing connection requests and network traffic.

      Under normal circumstances, never returns before close() is called. After close() is called, this function should return as soon as possible.

      If this method is called before init(), the behavior is undefined.

      Throws:
      IOException - If a fatal IO error occurs during any networking operation
    • run Link icon

      default void run()
      Method which implements the Runnable.run() function.

      This method is equivalent to start(), except that any IOExceptions thrown are wrapped into an UncheckedIOException. An application using this instance should use start() instead, to properly handle errors.

      Specified by:
      run in interface Runnable