October 24, 2018
Hot Topics:

Multithreaded Telnet Server - Chess Game Example

  • July 21, 1999
  • By Lee Patterson
  • Send Email »
  • More Articles »

This article was contributed by Lee Patterson.

This sample server demonstraites a server that can handle multiple TCP/IP connections. It also shows how to make a simple telnet server that could be used for things like administrating a server, making a chat room, or even creating a MUD.

The project that I chose was a chess server that could handle multiple games of Chess, with multiple players & watchers. This sample project uses a very handy blocking socket class called CBlockingSocket. The blocking socket class was found in the book titled Inside Visual C++ 5.0 by MS PRESS. This class is free, and can be used where ever, by whom ever. The class handles timeouts and errors by throwing an exception, so you aren't checking for errors all the time.

In order to facilitate making a telnet server, I derived a CTelnetSocket class from CBlockingSocket to handle mundane tasks like reading an entire line of data from the socket & printing text to the socket.

This is a very simple console application that demontrates:

  • Internet Server that accepts telnet connections.
  • Using multiple threads to handle more then one connection.
  • Blocking socket class for reading/writting/accepting connections from sockets.
    (I'd recomend this class over the MS CSocket and such, as they still have some 16-bit stuff in them, and this class ports to Unix a lot easier. That was the main goal of my program.)

Also included:

  • Simple linked list class that can be used anywhere (unix/mfc app/console app).
    Note: The linked list class is not thread safe.

The project and sample is included in ChessServer.zip. Use telnet as a client to connect to this server (ie: "telnet localhost"). You need to make sure your telnet client sends both CR & LF's.

See server.cpp for additional comments.


Download source & Sample - 49 KB


Date Posted: July 21, 1999
Last Updated:July 21, 1999

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date