Package org.omegazero.net.common
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
Represents any networking application (for example, a client or server).
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call tostart()to return.voidinit()Initializes this application.default voidrun()Method which implements theRunnable.run()function.voidstart()Runs the main loop of this instance.
-
Method Details
-
init
Initializes this application.- Throws:
IOException- If an IO error occurs during initialization
-
close
Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call tostart()to return.- Throws:
IOException- If an IO error occurs
-
start
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. Afterclose()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
default void run()Method which implements theRunnable.run()function.This method is equivalent to
start(), except that anyIOExceptions thrown are wrapped into anUncheckedIOException. An application using this instance should usestart()instead, to properly handle errors.
-