Go to the documentation of this file.
28#ifndef TCP_CLIENT_SERVER_H
29#define TCP_CLIENT_SERVER_H
31#include <itpp/itexports.h>
33#if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB) && !defined(itpp_EXPORTS))
35#ifndef ITPP_PROTOCOL_EXCLUDED
36#define ITPP_PROTOCOL_EXCLUDED
37#pragma message( "PROTOCOL definitions are not available for MSVC shared builds" )
71 write(packet, delta_time);
73 std::cout <<
"TcpServerApplication::write_to_net,"
74 <<
" byte_size=" << packet->
bit_size() / 8
88 tcp_receiver_p = tcp_recv_p;
89 tcp_sender_p = tcp_snd_p;
90 nbr_bytes_received = 0;
91 select.forward(
this, &TCP_Client_Application::received_packet_indication);
92 select.set_name(
"TcpClientApplicationSelectSlot");
104 nbr_bytes_to_receive = byte_size;
105 seq_num_val.set_size(10 + byte_size / 1460);
107 seq_num_time.set_size(10 + byte_size / 1460);
108 seq_num_time.zeros();
117 unsigned nbr_bytes_received;
118 unsigned nbr_bytes_to_receive;
124 void TCP_Client_Application::received_packet_indication(
int label) {
127 nbr_bytes_received = nbr_bytes_received + packet.
bit_size() / 8;
130 if (seq_num_index >= seq_num_time.size()) {
131 seq_num_time.set_size(2*seq_num_time.size(),
true);
132 seq_num_val.set_size(2*seq_num_val.size(),
true);
135 seq_num_val(seq_num_index) = nbr_bytes_received;
139 std::cout <<
"### sequence number: " << nbr_bytes_received
142 if (nbr_bytes_received >= nbr_bytes_to_receive) {
143 std::cout <<
"###### Stop sender and receiver" << std::endl;
147 seq_num_val.set_size(seq_num_index,
true);
148 seq_num_time.set_size(seq_num_index,
true);
149 save_to_file(
"seq_num.it");
153 void TCP_Client_Application::save_to_file(
string file) {
156 ff2 << Name(
"seq_num_val") << seq_num_val;
157 ff2 << Name(
"seq_num_time") << seq_num_time;
158 ff2 << Name(
"seq_num_index") << seq_num_index;
static Ttype now()
Return current time.
int bit_size()
get size of packet in bits
void set_name(const std::string &signal_name)
set name of signal
void set_debug(const bool enable_debug=true)
Set debug mode. If true all signals are printed to stdout.
Slot< TCP_Client_Application, int > select
ADD DOCUMENTATION HERE.
~TCP_Client_Application()
Destructor.
void read_from_net(unsigned byte_size)
ADD DOCUMENTATION HERE.
TCP_Client_Application(TCP_Sender *tcp_snd_p, TCP_Receiver *tcp_recv_p)
Default constructor.
virtual void release(std::string trace_filename="")
ADD DOCUMENTATION HERE.
itpp::Packet & get_user_message()
called by higher layer
virtual void release(std::string trace_filename="")
ADD DOCUMENTATION HERE.
virtual void save_trace(std::string filename)
ADD DOCUMENTATION HERE.
void write_to_net(unsigned byte_size, double delta_time)
ADD DOCUMENTATION HERE.
~TCP_Server_Application()
Destructor.
TCP_Server_Application()
Default constructor.
Signal< itpp::Packet * > write
ADD DOCUMENTATION HERE.
Definition of Transport Control Protocol (TCP)
Generated on Tue Dec 10 2024 04:49:37 for IT++ by Doxygen 1.12.0