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