Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/network_socket.h @ 9869

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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