Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/network/udp_broadcast.cc @ 9690

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

some network-stuff

File size: 2.0 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
20NewObjectListDefinition(UdpBroadcast);
21/**
22 * standard constructor
23 * @todo this constructor is not jet implemented - do it
24 */
25UdpBroadcast::UdpBroadcast ()
26{
27  this->port = 0;
28  packet = SDLNet_AllocPacket( BROADCAST_PACKET_SIZE );
29
30  if ( !packet )
31  {
32    printf( "SDLNet_AllocPacket: %s\n", SDLNet_GetError() );
33    assert( packet );
34  }
35
36  this->socket = NULL;
37}
38
39
40/**
41 * standard deconstructor
42 */
43UdpBroadcast::~UdpBroadcast ()
44{
45  if ( this->packet )
46  {
47    SDLNet_FreePacket( this->packet );
48    this->packet = NULL;
49  }
50
51  if ( this->socket )
52  {
53    SDLNet_UDP_Close( this->socket );
54    this->socket = NULL;
55  }
56
57}
58
59/**
60 * listen for incoming broadcast packets
61 * @param port port to listen on
62 * @return true on success
63 */
64bool UdpBroadcast::listen( int port )
65{
66  return true;
67}
68
69/**
70 * prepare for sending broadcast packets to port
71 * @param port port to send to
72 * @return true on success
73 */
74bool UdpBroadcast::open( int port )
75{
76  this->port = port;
77
78  return true;
79}
80
81/**
82 * send packet
83 * @param data data to send
84 * @param length length of data
85 * @param ip if ip == NULL broadcast is used
86 * @return number of bytes sent
87 */
88int UdpBroadcast::send( byte * data, int length, IPaddress * ip )
89{
90  return 0;
91}
92
93/**
94 * recieve packets
95 * @param data pointer to buffer to copy data to
96 * @param maxLength maxmal number of bytes to copy to data
97 * @param ip if != 0 ip contains data about sender
98 * @return number of bytes recieved
99 */
100int UdpBroadcast::recv( byte * data, int maxLength, IPaddress * ip )
101{
102  return 0;
103}
104
105
Note: See TracBrowser for help on using the repository browser.