Psyllid  v1.12.4
Project 8 Data Acquisisition Software
test_udp_server.cc
Go to the documentation of this file.
1 /*
2  * test_server.cc
3  *
4  * Created on: Dec 22, 2015
5  * Author: nsoblath
6  *
7  * Suggested UDP client: string_msg_client.go
8  */
9 
10 
11 #include "udp_server_socket.hh"
12 #include "psyllid_error.hh"
13 #include "logger.hh"
14 
15 using namespace psyllid;
16 
17 LOGGER( plog, "test_udp_server" );
18 
19 int main()
20 {
21  try
22  {
23  udp_server_socket t_server( 23530 );
24 
25  LINFO( plog, "Server is listening" );
26 
27  const size_t t_buff_size = 1024;
28  char* t_data = new char[ t_buff_size ];
29 
30  ssize_t t_size_received = 0;
31  while( t_size_received >= 0 )
32  {
33  LINFO( plog, "Waiting for a message" );
34  t_size_received = t_server.recv( t_data, t_buff_size, 0 );
35  if( t_size_received > 0 )
36  {
37  LINFO( plog, "Message received: " << t_data );
38  }
39  else
40  {
41  LDEBUG( plog, "No message received & no error present" );
42  }
43  }
44 
45  }
46  catch( std::exception& e )
47  {
48  LERROR( plog, "Exception caught: " << e.what() );
49  }
50 
51 }
static scarab::logger plog("batch_executor")
int main()
LOGGER(plog, "egg_writer")