Panda3D

Loading...
Searching...
No Matches
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 {
30PUBLISHED:
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
ConnectionManager
The primary interface to the low-level networking layer in this package.
Definition connectionManager.h:41
Connection::set_collect_tcp
void set_collect_tcp(bool collect_tcp)
Enables or disables "collect-tcp" mode.
Definition connection.cxx:112
Connection::set_recv_buffer_size
void set_recv_buffer_size(int size)
Sets the size of the receive buffer, in bytes.
Definition connection.cxx:238
Connection::set_collect_tcp_interval
void set_collect_tcp_interval(double interval)
Specifies the interval in time, in seconds, for which to hold TCP packets before sending all of the r...
Definition connection.cxx:130
Connection::consider_flush
bool consider_flush()
Sends the most recently queued TCP datagram(s) if enough time has elapsed.
Definition connection.cxx:149
Connection::flush
bool flush()
Sends the most recently queued TCP datagram(s) now.
Definition connection.cxx:173
Connection::set_keep_alive
void set_keep_alive(bool flag)
Sets whether the connection is periodically tested to see if it is still alive.
Definition connection.cxx:230
Connection::get_address
NetAddress get_address() const
Returns the address bound to this connection, if it is a TCP connection.
Definition connection.cxx:75
Connection::set_ip_time_to_live
void set_ip_time_to_live(int ttl)
Sets IP time-to-live.
Definition connection.cxx:257
Connection::get_collect_tcp_interval
double get_collect_tcp_interval() const
Returns the interval in time, in seconds, for which to hold TCP packets before sending all of the rec...
Definition connection.cxx:140
Connection::set_reuse_addr
void set_reuse_addr(bool flag)
Sets whether local address reuse is allowed.
Definition connection.cxx:221
Connection::get_manager
ConnectionManager * get_manager() const
Returns a pointer to the ConnectionManager object that serves this connection.
Definition connection.cxx:85
Connection::set_linger
void set_linger(bool flag, double time)
Sets whether nonblocking I/O should be in effect.
Definition connection.cxx:206
Connection::get_collect_tcp
bool get_collect_tcp() const
Returns the current setting of "collect-tcp" mode.
Definition connection.cxx:120
Connection::set_ip_type_of_service
void set_ip_type_of_service(int tos)
Sets IP type-of-service and precedence.
Definition connection.cxx:265
Connection::set_no_delay
void set_no_delay(bool flag)
If flag is true, this disables the Nagle algorithm, and prevents delaying of send to coalesce packets...
Definition connection.cxx:274
Connection::set_send_buffer_size
void set_send_buffer_size(int size)
Sets the size of the send buffer, in bytes.
Definition connection.cxx:246
Connection::Connection
Connection(ConnectionManager *manager, Socket_IP *socket)
Creates a connection.
Definition connection.cxx:36
Connection::set_max_segment
void set_max_segment(int size)
Sets the maximum segment size.
Definition connection.cxx:285
Connection::get_socket
Socket_IP * get_socket() const
Returns the internal Socket_IP that defines the connection.
Definition connection.cxx:93
LightReMutex
A lightweight reentrant mutex.
Definition lightReMutex.h:32
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
NetDatagram
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition netDatagram.h:40
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
lightReMutex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
netAddress.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.