Panda3D
netDatagram.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file netDatagram.cxx
10  * @author jns
11  * @date 2000-02-07
12  */
13 
14 #include "netDatagram.h"
15 
16 TypeHandle NetDatagram::_type_handle;
17 
18 /**
19  * Constructs an empty datagram.
20  */
23 }
24 
25 /**
26  * Constructs a datagram from an existing block of data.
27  */
29 NetDatagram(const void *data, size_t size) :
30  Datagram(data, size) {
31 }
32 
33 /**
34  *
35  */
37 NetDatagram(const Datagram &copy) :
38  Datagram(copy)
39 {
40 }
41 
42 /**
43  *
44  */
46 NetDatagram(const NetDatagram &copy) :
47  Datagram(copy),
48  _connection(copy._connection),
49  _address(copy._address)
50 {
51 }
52 
53 /**
54  *
55  */
56 void NetDatagram::
57 operator = (const Datagram &copy) {
58  Datagram::operator = (copy);
59  _connection.clear();
60  _address.clear();
61 }
62 
63 /**
64  *
65  */
66 void NetDatagram::
67 operator = (const NetDatagram &copy) {
68  Datagram::operator = (copy);
69  _connection = copy._connection;
70  _address = copy._address;
71 }
72 
73 /**
74  * Resets the datagram to empty, in preparation for building up a new
75  * datagram.
76  */
77 void NetDatagram::
78 clear() {
80  _connection.clear();
81  _address.clear();
82 }
83 
84 /**
85  * Specifies the socket to which the datagram should be written.
86  */
87 void NetDatagram::
88 set_connection(const PT(Connection) &connection) {
89  _connection = connection;
90 }
91 
92 /**
93  * Retrieves the socket from which the datagram was read, or to which it is
94  * scheduled to be written.
95  */
96 PT(Connection) NetDatagram::
97 get_connection() const {
98  return _connection;
99 }
100 
101 /**
102  * Specifies the host to which the datagram should be sent.
103  */
104 void NetDatagram::
105 set_address(const NetAddress &address) {
106  _address = address;
107 }
108 
109 /**
110  * Retrieves the host from which the datagram was read, or to which it is
111  * scheduled to be sent.
112  */
114 get_address() const {
115  return _address;
116 }
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:40
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
Definition: datagram.cxx:35
void clear()
Resets the NetAddress to its initial state.
Definition: netAddress.cxx:74
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
Definition: netDatagram.cxx:78
const NetAddress & get_address() const
Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.
PT(Connection) NetDatagram
Retrieves the socket from which the datagram was read, or to which it is scheduled to be written.
Definition: netDatagram.cxx:96
NetDatagram()
Constructs an empty datagram.
Definition: netDatagram.cxx:22
void set_connection(const PT(Connection) &connection)
Specifies the socket to which the datagram should be written.
Definition: netDatagram.cxx:88
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:29
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition: netAddress.h:25