Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5565 in orxonox.OLD for branches/network/src


Ignore:
Timestamp:
Nov 14, 2005, 11:06:20 PM (19 years ago)
Author:
hdavid
Message:

orxonox/branches/network: updated network_socket.h and network_socket.cc

Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_socket.cc

    r5542 r5565  
    1010
    1111### File Specific:
    12    main-programmer: ...
    13    co-programmer: ...
     12   main-programmer: Christoph, David Hasenfratz
     13   co-programmer:
    1414*/
    1515
     
    2424#include "network_socket.h"
    2525
     26/* header for debug output */
     27#include "debug.h"
     28
    2629
    2730/**
     
    2932 */
    3033NetworkSocket::NetworkSocket()
    31 {}
     34{
     35
     36        /* Init SDL_net */
     37        if(SDLNet_Init()==-1)
     38        {
     39        PRINTF(1)("SDLNet_Init: %s\n", SDLNet_GetError());
     40    return;
     41        }
     42        else
     43                PRINTF(5)("SDL_net initialized\n");
     44
     45}
    3246
    3347/**
     
    3650NetworkSocket::~ NetworkSocket( )
    3751{
     52
     53        /* Quit SDL_net */
     54        SDLNet_Quit();
     55        PRINTF(5)("SDL_net shutdown\n");
    3856}
    3957
    4058/**
    41  * Connect to another host
    42  */
    43 void NetworkSocket::connectToServer( )
     59  * This function establishes a TCP/UDP connection to a given server (function argument).
     60  * It is called by the NetworkStream. It creates a TCP/UDP socket for the connection.
     61  */
     62void NetworkSocket::connectToServer(IPaddress ip, unsigned int port)
    4463{
    4564}
    4665
    4766/**
    48  * Listen to a port number for incoming connections
    49  */
    50 void NetworkSocket::listen( )
     67  * Tells the NetworkSocket to listen on a specific port for incoming connections.
     68  * NetworkSocket::writeBytes(...) will have no effect until there is a valuable connection.
     69  */
     70void listen(unsigned int port)
    5171{
    5272}
    5373
    5474/**
    55  * Disconnect from server
     75 * DTears down a TCP/UDP connection.
    5676 */
    5777void NetworkSocket::disconnectServer( )
     
    6080
    6181/**
    62  * Write some data
    63  */
    64 void NetworkSocket::writeBytes( )
     82  * This function writes some bytes (data) to the network connection (if the connection is already
     83  * estabilhed) otherwise it just does nothing (silently discarding the data). And writes some
     84  * warnings
     85  */
     86void NetworkSocket::writeBytes(byte* data)
    6587{
    6688}
    6789
    68 /**
    69  * Read some data
    70  */
    71 void NetworkSocket::readBytes( )
     90 /**
     91  * Reads in the bytes from the network interface and passes it to the NetworkStream.
     92  * This function must internaly be implemented/connected as a thread, since the read
     93  * functions of many network libraries are blocking an would therefore block the whole
     94  * program.
     95  * From outside, the thread shouldn't be accessible at all.
     96  */
     97byte* NetworkSocket::readBytes()
    7298{
    7399}
    74 
  • branches/network/src/lib/network/network_socket.h

    r5533 r5565  
    88#define _NETWORK_SOCKET
    99
     10/* include this file, it contains some default definitions */
     11#include "netdefs.h"
     12
     13/* include SDL_net header */
     14#include "SDL_net.h"
     15
     16/* using namespace std is default, this needs to be here */
     17using namespace std;
    1018
    1119class NetworkSocket
    1220{
     21
     22private:
     23        IPaddress serverAddress;
     24        unsigned int port;
     25        TCPsocket tcpSocket;
     26        UDPsocket udpSocket;
    1327
    1428public:
     
    1731  ~NetworkSocket();
    1832
    19   void connectToServer();
    20   void listen();
     33  void connectToServer(IPaddress ip, unsigned int port);
     34  void listen(unsigned int port);
    2135  void disconnectServer();
    22   void writeBytes();
    23         void readBytes();
     36  void writeBytes(byte* data);
     37  byte* readBytes();
    2438
    2539};
Note: See TracChangeset for help on using the changeset viewer.