summaryrefslogtreecommitdiffstats
path: root/examples/network/infoprotocol/infoserver/server.h
blob: 33fb678210f788f5fd1127e214b05790f884c135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/****************************************************************************
**
** Copyright (C) 1992-2008 Trolltech ASA.  All rights reserved.
**
** This file is part of an example program for TQt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#ifndef SERVER_H
#define SERVER_H

#include <ntqsocket.h>
#include <ntqserversocket.h>

#include "infodata.h"
#include "serverbase.h"

static const Q_UINT16 infoPort = 42417;


/*
  The ServerInfo class provides a small GUI for the server. It also creates the
  SimpleServer and as a result the server.
*/
class ServerInfo : public ServerInfoBase
{
    TQ_OBJECT
public:
    ServerInfo( Q_UINT16 port = infoPort, TQWidget *parent = 0, const char *name = 0 );

private slots:
    void newConnect();
};


class SimpleServer : public TQServerSocket
{
    TQ_OBJECT
public:
    SimpleServer( Q_UINT16 port = infoPort, TQObject* parent = 0, const char *name = 0 );
    void newConnection( int socket );

signals:
    void newConnect();

private:
    InfoData info;
};


class ClientSocket : public TQSocket
{
    TQ_OBJECT
public:
    ClientSocket( int sock, InfoData *i, TQObject *parent = 0, const char *name = 0 );

private slots:
    void readClient();
    void connectionClosed();

private:
    TQString processCommand( const TQString& command );
    InfoData *info;
};


#endif //SERVER_H