14#ifndef CONNECTIONREADER_H
15#define CONNECTIONREADER_H
26#include "socket_fdset.h"
64 const std::string &thread_name = std::string());
86 virtual void flush_read_connection(Connection *connection);
87 virtual void receive_datagram(
const NetDatagram &datagram)=0;
91 SocketInfo(
const PT(Connection) &connection);
95 PT(Connection) _connection;
99 typedef pvector<SocketInfo *> Sockets;
101 void clear_manager();
102 void finish_socket(SocketInfo *sinfo);
104 virtual bool process_incoming_data(SocketInfo *sinfo);
105 virtual bool process_incoming_udp_data(SocketInfo *sinfo);
106 virtual bool process_incoming_tcp_data(SocketInfo *sinfo);
107 virtual bool process_raw_incoming_udp_data(SocketInfo *sinfo);
108 virtual bool process_raw_incoming_tcp_data(SocketInfo *sinfo);
111 ConnectionManager *_manager;
118 Sockets _removed_sockets;
123 void thread_run(
int thread_index);
125 SocketInfo *get_next_available_socket(
bool allow_block,
126 int current_thread_index);
128 void rebuild_select_list();
133 int _tcp_header_size;
136 class ReaderThread :
public Thread {
140 virtual void thread_main();
146 typedef pvector< PT(ReaderThread) > Threads;
153 Sockets _selecting_sockets;
163 AtomicAdjust::Integer _currently_polling_thread;
165 friend class ConnectionManager;
166 friend class ReaderThread;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The primary interface to the low-level networking layer in this package.
bool remove_connection(Connection *connection)
Removes a socket from the list of sockets being monitored.
void poll()
Explicitly polls the available sockets to see if any of them have any noise.
bool add_connection(Connection *connection)
Adds a new socket to the list of sockets the ConnectionReader will monitor.
int get_tcp_header_size() const
Returns the current setting of TCP header size.
bool is_polling() const
Returns true if the reader is a polling reader, i.e.
void set_tcp_header_size(int tcp_header_size)
Sets the header size of TCP packets.
ConnectionReader(ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
Creates a new ConnectionReader with the indicated number of threads to handle requests.
int get_num_threads() const
Returns the number of threads the ConnectionReader has been created with.
ConnectionManager * get_manager() const
Returns a pointer to the ConnectionManager object that serves this ConnectionReader.
void set_raw_mode(bool mode)
Sets the ConnectionReader into raw mode (or turns off raw mode).
bool is_connection_ok(Connection *connection)
Returns true if the indicated connection has been added to the ConnectionReader and is being monitore...
bool get_raw_mode() const
Returns the current setting of the raw mode flag.
void shutdown()
Terminates all threads cleanly.
This is a standard, non-reentrant mutex, similar to the Mutex class.
A standard mutex, or mutual exclusion lock.
A specific kind of Datagram, especially for sending across or receiving from a network.
A simple place to store and manipulate tcp and port address for communication layer.
Base functionality for a INET domain Socket This call should be the starting point for all other unix...
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.