#pragma once
#include<boost/array.hpp>
#include<boost/system/system_error.hpp>
#include <boost/asio.hpp>
namespace UdpSyClient
{
using namespace boost::asio::ip;
const int MaxSize = 1024;
void udp_sy_client()
{
try
{
boost::asio::io_service io;
udp::resolver resolver(io);
udp::resolver::query query(udp::v4(), "localhost", "6677");//protocol type , ip , port
udp::endpoint resolver_endpoint = *resolver.resolve(query);
udp::socket socket(io);
socket.open(udp::v4());
boost::array<char, 1> buf = {
{0}};
socket.send_to(boost::asio::buffer(buf), resolver_endpoint);
boost::array<char, MaxSize> recive_buf;
udp::endpoint send_endpoint;
size_t len = socket.receive_from(boost::asio::buffer(recive_buf), send_endpoint);
std::cout.write(recive_buf.data(), len);
}
catc