Panda3D

Loading...
Searching...
No Matches
datagramSinkNet.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 datagramSinkNet.h
10 * @author drose
11 * @date 2009-02-15
12 */
13
14#ifndef DATAGRAMSINKNET_H
15#define DATAGRAMSINKNET_H
16
17#include "pandabase.h"
18
19#include "datagramSink.h"
20#include "connectionWriter.h"
21
22/**
23 * This class accepts datagrams one-at-a-time and sends them over the net, via
24 * a TCP connection.
25 */
26 class EXPCL_PANDA_NET DatagramSinkNet : public DatagramSink, public ConnectionWriter {
27PUBLISHED:
28 explicit DatagramSinkNet(ConnectionManager *manager, int num_threads);
29
30 INLINE void set_target(Connection *connection);
31 INLINE Connection *get_target() const;
32
33 // Inherited from DatagramSink
34 virtual bool put_datagram(const Datagram &data);
35 virtual bool is_error();
36 virtual void flush();
37
38 private:
39 PT(Connection) _target;
40};
41
42#include "datagramSinkNet.I"
43
44#endif
ConnectionWriter::ConnectionWriter
ConnectionWriter(ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
Creates a new ConnectionWriter with the indicated number of threads to handle output.
Definition connectionWriter.cxx:52
DatagramSinkNet::set_target
void set_target(Connection *connection)
Specifies the Connection that will receive all future Datagrams sent.
Definition datagramSinkNet.I:18
DatagramSinkNet::flush
virtual void flush()
Ensures that all datagrams previously written will be visible on the stream.
Definition datagramSinkNet.cxx:55
DatagramSinkNet::DatagramSinkNet
DatagramSinkNet(ConnectionManager *manager, int num_threads)
Creates a new DatagramSinkNet with the indicated number of threads to handle writing.
Definition datagramSinkNet.cxx:24
DatagramSinkNet::is_error
virtual bool is_error()
Returns true if there is an error on the target connection, or if the target has never been set.
Definition datagramSinkNet.cxx:46
DatagramSinkNet::get_target
Connection * get_target() const
Returns the current target Connection, or NULL if the target has not yet been set.
Definition datagramSinkNet.I:27
DatagramSinkNet::put_datagram
virtual bool put_datagram(const Datagram &data)
Sends the given datagram to the target.
Definition datagramSinkNet.cxx:34
DatagramSink::DatagramSink
DatagramSink()
Does nothing since this is class is just the definition of an interface.
Definition datagramSink.I:18
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
connectionWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagramSinkNet.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagramSink.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.