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);
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;
171 #endif //TCP_CLIENT_SERVER_H