Panda3D
datagramTCPHeader.h
1 // Filename: datagramTCPHeader.h
2 // Created by: drose (08Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DATAGRAMTCPHEADER_H
16 #define DATAGRAMTCPHEADER_H
17 
18 #include "pandabase.h"
19 
20 #include "netDatagram.h"
21 
22 #include "datagramIterator.h"
23 #include "numeric_types.h"
24 
25 static const int datagram_tcp16_header_size = sizeof(PN_uint16);
26 static const int datagram_tcp32_header_size = sizeof(PN_uint32);
27 
28 class NetDatagram;
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : DatagramTCPHeader
32 // Description : A class that encapsulates the extra bytes that are
33 // sent in front of each datagram to identify it when it
34 // is sent on TCP. This is similar to
35 // DatagramUDPHeader, except it does not include a
36 // checksum, since this is unnecessary on UDP.
37 ////////////////////////////////////////////////////////////////////
38 class EXPCL_PANDA_NET DatagramTCPHeader {
39 public:
40  DatagramTCPHeader(const NetDatagram &datagram, int header_size);
41  DatagramTCPHeader(const void *data, int header_size);
42 
43  int get_datagram_size(int header_size) const;
44  INLINE string get_header() const;
45 
46  bool verify_datagram(const NetDatagram &datagram, int header_size) const;
47 
48 private:
49  // The actual data for the header is stored (somewhat recursively)
50  // in its own NetDatagram object. This is just for convenience of
51  // packing and unpacking the header.
52  NetDatagram _header;
53 };
54 
55 #include "datagramTCPHeader.I"
56 
57 #endif
58 
59 
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:43
A class that encapsulates the extra bytes that are sent in front of each datagram to identify it when...