Panda3D
Loading...
Searching...
No Matches
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
16TypeHandle NetDatagram::_type_handle;
17
18/**
19 * Constructs an empty datagram.
20 */
24
25/**
26 * Constructs a datagram from an existing block of data.
27 */
29NetDatagram(const void *data, size_t size) :
30 Datagram(data, size) {
31}
32
33/**
34 *
35 */
37NetDatagram(const Datagram &copy) :
38 Datagram(copy)
39{
40}
41
42/**
43 *
44 */
46NetDatagram(const NetDatagram &copy) :
47 Datagram(copy),
48 _connection(copy._connection),
49 _address(copy._address)
50{
51}
52
53/**
54 *
55 */
56void NetDatagram::
57operator = (const Datagram &copy) {
58 Datagram::operator = (copy);
59 _connection.clear();
60 _address.clear();
61}
62
63/**
64 *
65 */
66void NetDatagram::
67operator = (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 */
78clear() {
80 _connection.clear();
81 _address.clear();
82}
83
84/**
85 * Specifies the socket to which the datagram should be written.
86 */
88set_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 */
96PT(Connection) NetDatagram::
97get_connection() const {
98 return _connection;
99}
100
101/**
102 * Specifies the host to which the datagram should be sent.
103 */
104void NetDatagram::
105set_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 */
114get_address() const {
115 return _address;
116}
Represents a single TCP or UDP socket for input or output.
Definition connection.h:29
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
Definition datagram.cxx:35
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition netAddress.h:25
void clear()
Resets the NetAddress to its initial state.
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.
const NetAddress & get_address() const
Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.
NetDatagram()
Constructs an empty datagram.
void set_connection(const PT(Connection) &connection)
Specifies the socket to which the datagram should be written.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.