my dog learned polymorphism
The moose likes Sockets and Internet Protocols and the fly likes How to write telnet server like program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How to write telnet server like program?" Watch "How to write telnet server like program?" New topic

How to write telnet server like program?

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 397
I need to write a program similar to a telnet server. A telnet server
asynchronously reads data from a socket and writes it to a
sub-process, and asynchronously reads data from the subprocess and
writes to a socket. My program needs to replace the subprocess with a
serial port.

The telnet server cannot anticipate when data will arrive from the
socket. Neither can it anticipate when data will arrive from the

How can I write a similar OS vendor neutral program using Java or
Groovy or Jython, except, instead reading and writing to a process, I
read and write to serial port? Can I do this with a single thread? How
do I read and write to a serial port? Can anyone point me to some
sample code for serial port I/O?

Mark Griffin

Joined: Jun 25, 2003
Posts: 7
It sounds like you are developing a front end for a serial device.

The "front end" is a socket server. It accepts socket connections from clients and passes information back and forth between the clients and the serial attached device.

If that's the jist of it then you need two things to get started.

1) an example socket server program. Simple ones that just create a Server Socket, accpet connections, and pass the connection off to a new thread are easy to find.

2) a set of classes for communication with a serial port. That's a little trickier - there are payware SDKs for this. Maybe you can find something on sourceforge.

ALTERNATIVELY you could use a servlet container like Tomcat to handle the client connections and just write a servlet that talks to the serial attached device. You still need a serial port SDK.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Moving to Sockets and Internet Protocols...

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: How to write telnet server like program?
jQuery in Action, 3rd edition