Skip to main content

This page is available in Simplified Chinese.

TCP Echo server

The repository’s AioEchoServer receives one line of text and sends it back to the client. In your IDE, run its main method with neta-core on the classpath.

  1. NetManager listens on TCP port 5567.
  2. LineBasedFrameHandler splits the input into lines, and StringHandler converts between bytes and strings.
  3. The application subscribes to inbound messages and replies through NetChannel.sendData with echo followed by the text it received.

Connect locally with telnet 127.0.0.1 5567. Type hello and press Enter. The server returns echo hello. Press Enter in the server console to exit the example.

See Protocol pipelines for more details.