/*! \mainpage Paradigm
\image html logo.gif

\section intro Introduction
The TCP/IP network progamming examples I've seen generally ignore
error detection and handling.  Unfortunately this often results
in poor quality servers being releasing by those who learn by example.
This program features exhaustive error detection and handling.
Memory leaks and buffer overruns are also ubiquitous in TCP/IP servers.
This example attempts to mitigate those issues.  At least that's the
hope.

\section desc Description
Paradigm in its current state is a very primitive chat server written
in C++ for Win32 systems supporting Winsock2.  It allows multiple
connections and just echoes input to all those connected.

\section feat Features
- Proper error detection.
- Dynamic buffers.
- Lots of fuzzy comments using Doxygen QT style notation.

\section impl Implementation
A non-blocking select-based server model was selected for this
illustration for no particular reason other than usefulness of the
example to other BSD derived TCP/IP stack implementations.<p>
There are no actual winsock2 dependencies in this version despite
the negotiation present for winsock2.  It should work on winsock1
systems by modifiying the WSAStartup negotiation and including the
appropriate headers.

\section depend System Dependencies
This version was compiled and tested with the following compilers:
- Borland 5.3   (Borland Builder 3.0)
- Borland 5.5.1 (Borland's free commandline compiler)

\section install Installation
\subsection bb3 Borland Builder 3.0 IDE
-# Unzip the distribution into the folders it wants.
-# Start Builder and open the project group (paradigm_1.bpg)
  in the paradigm directory.
-# Click build
-# Open a Windows command console window and switch to the paradigm
  directory by typing: <b>cd c:\\paradigm</b> or to the path
  you placed it.
-# Run the server by typing: <b>paradigm</b><p>

\subsection bc55 Borland's Free Command Line Compiler
-# Unzip the distribution into the folders it wants.
-# Open a Windows command console window and switch to the paradigm
  directory by typing: <b>cd c:\\paradigm</b> or to the path
  you placed it.
-# Then type: <b>make</b> and watch it compile.
-# Run the server by typing: <b>paradigm</b>

\subsection bb3 VIDE with Borland's Free Command Line Compiler
-# Unzip the distribution into the folders it wants.
-# Start VIDE and open the project file (paradigm_1.vpj)
  in the paradigm directory.
-# Click on make
-# Open a Windows command console window and switch to the paradigm
  directory by typing: <b>cd c:\\paradigm</b> or to the path
  you placed it.
-# Run the server by typing: <b>paradigm</b><p>

\section license License
Paradigm was &copy; 2003 by Jon A. Lambert - All Rights Reserved.<br>
Paradigm has been released to the public domain by Jon A. Lambert.<br>

\section misc Miscellaneous
\subsection notes Notes on operation
- @shutdown will shut down the server
- anything else echos to all connected<p>

\subsection future Future
There ain't to many places to go without complicating this.
- One should separate the Network from Chat server...err but what
chat server?
- It might be nice to support a some telnet negotiation.
- A multithreaded implementation.
- Illustrations of other network designs, asynchronous sockets
and/or IOCP edge detection.
- A port to BSD or Linux<p>

\subsection contact Contact and Other Information

\author Jon A. Lambert<br>
aka Tyche<br>
Email: jlsysinc@alltel.net
\date 02/15/2003
\version 0.10
*/

/*! \file paradigm.cpp
  This is the main entry point that starts the Paradigm server

  \author Jon A. Lambert
  \date 04/28/2003
  \version 0.10

  \notes
  Commands -
    @shutdown - shuts down the server

 */

#include "sysconfig.h"
#include "server.h"

#if (__BORLANDC__ < 0x550)
#include <condefs.h>
USEUNIT("connection.cpp");
USEUNIT("server.cpp");
//---------------------------------------------------------------------------
#endif


//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char **argv) {
    WSADATA wsaData;
    int err = WSAStartup(0x202, &wsaData);
    if (err)
        cout << "Error-main(WSAStartup):" << err << endl;
    Server* chatserver = Server::Instance();
    if (chatserver->Boot(32000))
        chatserver->Run();
    chatserver->Destroy();
    WSACleanup();
    return 0;
}