Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/udp_broadcast.cc @ 10762

Last change on this file since 10762 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: 1.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Christoph Renner
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "udp_broadcast.h"
19
20/**
21 * standard constructor
22 * @todo this constructor is not jet implemented - do it
23 */
24UdpBroadcast::UdpBroadcast ()
25{
26  this->port = 0;
27  packet = SDLNet_AllocPacket( BROADCAST_PACKET_SIZE );
28
29  if ( !packet )
30  {
31    printf( "SDLNet_AllocPacket: %s\n", SDLNet_GetError() );
32    assert( packet );
33  }
34
35  this->socket = NULL;
36}
37
38
39/**
40 * standard deconstructor
41 */
42UdpBroadcast::~UdpBroadcast ()
43{
44  if ( this->packet )
45  {
46    SDLNet_FreePacket( this->packet );
47    this->packet = NULL;
48  }
49
50  if ( this->socket )
51  {
52    SDLNet_UDP_Close( this->socket );
53    this->socket = NULL;
54  }
55
56}
57
58/**
59 * listen for incoming broadcast packets
60 * @param port port to listen on
61 * @return true on success
62 */
63bool UdpBroadcast::listen( int port )
64{
65  return true;
66}
67
68/**
69 * prepare for sending broadcast packets to port
70 * @param port port to send to
71 * @return true on success
72 */
73bool UdpBroadcast::open( int port )
74{
75  this->port = port;
76
77  return true;
78}
79
80/**
81 * send packet
82 * @param data data to send
83 * @param length length of data
84 * @param ip if ip == NULL broadcast is used
85 * @return number of bytes sent
86 */
87int UdpBroadcast::send( byte * data, int length, IPaddress * ip )
88{
89  return 0;
90}
91
92/**
93 * recieve packets
94 * @param data pointer to buffer to copy data to
95 * @param maxLength maxmal number of bytes to copy to data
96 * @param ip if != 0 ip contains data about sender
97 * @return number of bytes recieved
98 */
99int UdpBroadcast::recv( byte * data, int maxLength, IPaddress * ip )
100{
101  return 0;
102}
103
104
Note: See TracBrowser for help on using the repository browser.