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
  • Method Summary

    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.

    This method is equivalent to start(), except that any IOExceptions thrown are wrapped into a RuntimeException.
    void
    Runs the main loop of this instance.
  • Method Details

    • init

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

      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

      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, should never return 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 an IO error occurs during any networking operation
    • run

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

      This method is equivalent to start(), except that any IOExceptions thrown are wrapped into a RuntimeException. An application using this instance may want to use start() instead, to properly handle errors.
      Specified by:
      run in interface Runnable