Panda3D
connection.h
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 connection.h
10  * @author jns
11  * @date 2000-02-07
12  */
13 
14 #ifndef CONNECTION_H
15 #define CONNECTION_H
16 
17 #include "pandabase.h"
18 #include "referenceCount.h"
19 #include "netAddress.h"
20 #include "lightReMutex.h"
21 
22 class Socket_IP;
23 class ConnectionManager;
24 class NetDatagram;
25 
26 /**
27  * Represents a single TCP or UDP socket for input or output.
28  */
29 class EXPCL_PANDA_NET Connection : public ReferenceCount {
30 PUBLISHED:
31  explicit Connection(ConnectionManager *manager, Socket_IP *socket);
32  ~Connection();
33 
34  NetAddress get_address() const;
35  ConnectionManager *get_manager() const;
36 
37  Socket_IP *get_socket() const;
38 
39  void set_collect_tcp(bool collect_tcp);
40  bool get_collect_tcp() const;
41  void set_collect_tcp_interval(double interval);
42  double get_collect_tcp_interval() const;
43 
44  BLOCKING bool consider_flush();
45  BLOCKING bool flush();
46 
47  // Socket options. void set_nonblock(bool flag);
48  void set_linger(bool flag, double time);
49  void set_reuse_addr(bool flag);
50  void set_keep_alive(bool flag);
51  void set_recv_buffer_size(int size);
52  void set_send_buffer_size(int size);
53  void set_ip_time_to_live(int ttl);
54  void set_ip_type_of_service(int tos);
55  void set_no_delay(bool flag);
56  void set_max_segment(int size);
57 
58 private:
59  bool send_datagram(const NetDatagram &datagram, int tcp_header_size);
60  bool send_raw_datagram(const NetDatagram &datagram);
61  bool do_flush();
62  bool check_send_error(bool okflag);
63 
64  ConnectionManager *_manager;
65  Socket_IP *_socket;
66  LightReMutex _write_mutex;
67 
68  bool _collect_tcp;
69  double _collect_tcp_interval;
70  double _queued_data_start;
71  std::string _queued_data;
72  int _queued_count;
73 
74  friend class ConnectionWriter;
75 };
76 
77 #endif
Socket_IP
Base functionality for a INET domain Socket This call should be the starting point for all other unix...
Definition: socket_ip.h:27
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ReferenceCount
A base class for all things that want to be reference-counted.
Definition: referenceCount.h:38
Connection
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:29
NetAddress
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition: netAddress.h:25
ConnectionWriter
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
Definition: connectionWriter.h:35
netAddress.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ConnectionManager
The primary interface to the low-level networking layer in this package.
Definition: connectionManager.h:41
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NetDatagram
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:40
LightReMutex
A lightweight reentrant mutex.
Definition: lightReMutex.h:30
lightReMutex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.