-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestClient.cpp
33 lines (31 loc) · 874 Bytes
/
testClient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include "Poco/Net/DatagramSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Timestamp.h"
#include "Poco/DateTimeFormatter.h"
#include <string>
int main()
{
const char* ipaddr = "127.0.0.1";
Poco::Net::SocketAddress sa("127.0.0.1", 5000);
Poco::Net::DatagramSocket dgs;
//dgs.connect(sa);
std::string syslogMsg;
Poco::Timestamp now;
//syslogMsg = Poco::DateTimeFormatter::format(now, "<14>%w %f %H:%M:%S Hello,world!");
syslogMsg="123456";
//for(int i=0;i<1000;i++)
//syslogMsg+="t";
int count=0;
char buffer[2156];
while(true){
count++;
if(count%1000==0)std::cout<<count<<std::endl;
dgs.sendTo(syslogMsg.data(), syslogMsg.size(),sa);
int n = dgs.receiveFrom(buffer, sizeof(buffer) - 1,sa);
buffer[n] = '\0';
std::cout << sa.toString() << ": " << buffer << std::endl;
break;
}
return 0;
}