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 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#include "ns3/address.h"
8#include "ns3/application.h"
9#include "ns3/node.h"
10#include "ns3/ptr.h"
11#include "ns3/socket.h"
12
13namespace ns3
14{
15
16/**
17 * \ingroup system-tests-tcp
18 *
19 * \brief Simple class to write data to sockets.
20 */
22{
23 public:
25 ~SocketWriter() override;
26 /**
27 * Register this type.
28 * \return The TypeId.
29 */
30 static TypeId GetTypeId();
31
32 /**
33 * Setup the socket.
34 * \param node The node owning the socket.
35 * \param peer The destination address.
36 */
37 void Setup(Ptr<Node> node, Address peer);
38 /**
39 * Connect the socket.
40 */
41 void Connect();
42 /**
43 * Write to the socket.
44 * \param numBytes The number of bytes to write.
45 */
46 void Write(uint32_t numBytes);
47 /**
48 * Close the socket.
49 */
50 void Close();
51
52 private:
53 void StartApplication() override;
54 void StopApplication() override;
55 Address m_peer; //!< Peer's address.
56 Ptr<Node> m_node; //!< Node pointer
57 Ptr<Socket> m_socket; //!< Socket.
58 bool m_isSetup; //!< True if the socket is connected.
59 bool m_isConnected; //!< True if the socket setup has been done.
60};
61} // namespace ns3
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
Smart pointer class similar to boost::intrusive_ptr.
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:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.