users@grizzly.java.net

Re: Sample Code for TCP Server and Client

From: Erik Svensson <erik_at_phlogiston.se>
Date: Mon, 12 May 2008 22:23:28 +0200

> I am desperately looking for an TCP Server and client example code
> which does the following
>
> 1. Client writes a text message say Hello to the Server listening
> on port say 9090.
> 2. Server reads the messages send by the client and prints it.
> 3. Server writes back to the Client by appending some text to the
> received message
> 4. Client receives the message from the server and prints it.
>
> Any help is greatly appreciated.

If you look here https://grizzly.dev.java.net/tutorials/client-ant-
tutorial/index.html, it tells you how to create a client.
It also includes the source for an echo server. The grizzly
distributiion contains the source for the echo-filter.
Take a look at that and modify it according to your needs. That
should just about fill your needs.

cheers

/Erik
Phlogiston

'Nobody is innocent.'
-- Agent Rogersz, 'Repoman'