Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/lib/network/network_socket.h @ 10620

Last change on this file since 10620 was 9406, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

File size: 2.0 KB
Line 
1/*!
2 * @file network_socket.h
3  *  Main interface for the network module. Manages all the modules
4
5*/
6
7#ifndef _NETWORK_SOCKET
8#define _NETWORK_SOCKET
9
10/* include this file, it contains some default definitions */
11#include "netdefs.h"
12
13
14/* include base_object.h since all classes are derived from this one */
15#include "base_object.h"
16
17class NetworkSocket : public BaseObject
18{
19  public:
20    NetworkSocket();
21    virtual ~NetworkSocket();
22
23    /**
24     * connect to server on host with port port
25     * @param host hostname might be xxx.xxx.xxx.xxx or localhost ...
26     * @param port port to connect to
27     */
28    virtual void connectToServer( std::string host, int port ) = 0;
29
30    /**
31     * disconnect from server
32     */
33    virtual void disconnectServer() = 0;
34
35    /**
36     * reconnecting to another server by terminating old connection and init a new connection
37     */
38    virtual void reconnectToServer( std::string host, int port) = 0;
39
40    /**
41     * reconnecting to anoter server softly
42     */
43    virtual void reconnectToServerSoft( std::string host, int port) = 0;
44
45    /**
46     * send packet to connected socket. will be recieved as whole packet
47     * @param data pointer to data to send
48     * @param length lengt of packet to send
49     * @return true on success
50     */
51    virtual bool writePacket(byte * data, int length) = 0;
52
53    /**
54     * read a packet sent by another NetworkSocket
55     * @param data data will be copied here
56     * @param maxLength readPacket will not read more than maxLength
57     * @return bytes read. on error less than zero
58     */
59    virtual int readPacket(byte * data, int maxLength) = 0;
60
61    /**
62     * check if socket is ok
63     * @return true if socket is ok
64     */
65    inline bool isOk() { return this->bOk; }
66
67    /** @returns the ip adderess of the destination socket */
68    IPaddress getRemoteAddress() { return ip; }
69
70
71  protected:
72    bool              bOk;            //!< check for socket status
73
74    IPaddress         ip;             //!< host,port
75};
76
77
78
79#endif /* _NETWORK_SOCKET */
Note: See TracBrowser for help on using the repository browser.