A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3tcp-socket-writer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include "ns3/address.h"
19#include "ns3/application.h"
20#include "ns3/node.h"
21#include "ns3/ptr.h"
22#include "ns3/socket.h"
23
24namespace ns3
25{
26
27/**
28 * \ingroup system-tests-tcp
29 *
30 * \brief Simple class to write data to sockets.
31 */
33{
34 public:
36 ~SocketWriter() override;
37 /**
38 * Register this type.
39 * \return The TypeId.
40 */
41 static TypeId GetTypeId();
42
43 /**
44 * Setup the socket.
45 * \param node The node owning the socket.
46 * \param peer The destination address.
47 */
48 void Setup(Ptr<Node> node, Address peer);
49 /**
50 * Connect the socket.
51 */
52 void Connect();
53 /**
54 * Write to the socket.
55 * \param numBytes The number of bytes to write.
56 */
57 void Write(uint32_t numBytes);
58 /**
59 * Close the socket.
60 */
61 void Close();
62
63 private:
64 void StartApplication() override;
65 void StopApplication() override;
66 Address m_peer; //!< Peer's address.
67 Ptr<Node> m_node; //!< Node pointer
68 Ptr<Socket> m_socket; //!< Socket.
69 bool m_isSetup; //!< True if the socket is connected.
70 bool m_isConnected; //!< True if the socket setup has been done.
71};
72} // namespace ns3
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simple class to write data to sockets.
Address m_peer
Peer's address.
static TypeId GetTypeId()
Register this type.
void Connect()
Connect the socket.
void Setup(Ptr< Node > node, Address peer)
Setup the socket.
void Write(uint32_t numBytes)
Write to the socket.
Ptr< Node > m_node
Node pointer.
void Close()
Close the socket.
bool m_isSetup
True if the socket is connected.
void StopApplication() override
Application specific shutdown code.
Ptr< Socket > m_socket
Socket.
bool m_isConnected
True if the socket setup has been done.
void StartApplication() override
Application specific startup code.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.