You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
3.5 KiB
C++

//:Header:8, "CServer", 39ab9144
//
// File: cserver.h
//
// Copyright (C) 2000 Piko, All rights reserved.
//
// Modification History:
// 29 Aug 2000, PIKO -- Generated 12:32:36 by Genitor V4.50.621.2
//
//:---------------------------------------------------------------------------
#if !defined(CSERVER_INCLUDED)
#define CSERVER_INCLUDED
#if !defined(_WIN32) && !defined(_UNIX)
#define _UNIX
#endif
//:Include
#if !defined(_UNIX)
#ifdef UNDER_CE
#include <winsock.h>
#else
#include <winsock2.h>
#endif
#else // defined(_UNIX)
#include <unistd.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#endif // defined(_UNIX)
//#include "cpreferences.h"
//#include "csimplelist.h"
#include "cserver.h"
//#include "cclient.h"
//:Custom
#ifndef INVALID
#define INVALID (-1)
#endif
#if !defined(_UNIX)
#pragma comment(lib,"wsock32.lib")
#endif /* !defined(_UNIX) */
//:End Custom
//:> +---------------------------------+
//:>-------------------| CServer Class Declaration |--------------------
//:> +---------------------------------+
//:Class
class CServer
{
friend int main(int ac, char **av);
public:
//::1
// +-----------------------+
// | Default Constructor |
// +-----------------------+
//:Description
//
// Default constructor.
//
CServer();
//::2
// +--------------+
// | Destructor |
// +--------------+
//:Description
//
// Destructor.
//
virtual ~CServer();
//::3
// +-----------------+
// | CloseServer() |
// +-----------------+
void CloseServer();
//::7
// +----------+
// | Dump() |
// +----------+
//::4
// +------------------+
// | GetLastError() |
// +------------------+
int GetLastError();
//::5
// +-------------+
// | StartUp() |
// +-------------+
void StartUp(
int p_port, bool p_udp=false ); // serverport für die windows clients, udp flag
int GetSockHandle(){ return m_clientlistensock; };
int StartUpAsClient(const char *ipaddr, int port, bool p_udp=false );
int StartUpAsClient(unsigned int ipaddr, int port, bool p_udp=false );
int Write(char * buf, int cnt = 0);
private:
//:=5
// +----------------------+
// | m_clientlistensock |
// +----------------------+
int m_clientlistensock; // Server Socket Handle für die Windows Clients
//:=6
// +---------------+
// | m_lasterror |
// +---------------+
int m_lasterror; // fehlernummer vom letzten befehl
//:=7
// +----------------------+
// | m_clientlistenport |
// +----------------------+
int m_clientlistenport; // portnummer
int m_starttime; // startzeit
struct sockaddr_in m_destaddr; // wenn als client gestartet
};
#if defined(_UNIX)
//:> +------------------------------------+
//:>------------------| Global Function Declarations |------------------
//:> +------------------------------------+
//::6
// +-----------------+
// | closesocket() |
// +-----------------+
inline int closesocket(
int handle);
//:> +-----------------------------------+
//:>------------------| Global Function Definitions |-------------------
//:> +-----------------------------------+
//::6
// +-----------------+
// | closesocket() |
// +-----------------+
inline int closesocket(
int handle)
{
return close(handle);
}
#endif // defined(_UNIX)
#endif // CSERVER_INCLUDED