Exception Boost::asio

Hello guys i have this code in vc++
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
34
// Boost.cpp : definisce il punto di ingresso dell'applicazione console.
//

#include "stdafx.h"
#include <iostream>
#include <boost\thread.hpp>
#include <boost\array.hpp>
#include <boost\asio.hpp>
using namespace std;

bool send(string host, int port, string mess) {
	
	boost::asio::io_service ios;
	boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(host), port);
	boost::asio::ip::tcp::socket socket(ios);
	socket.connect(endpoint);
	//boost::array<char, 128> buf;
	char buf[128];
	copy(mess.begin(), mess.end(), buf);
	boost::system::error_code error;
	socket.write_some(boost::asio::buffer(buf, mess.size()), error);
	socket.close();
	return 0;
}

int main(int argc, char* argv[])
{
	
	send("127.0.0.1", 1212, "HellO From?");

	system("pause");
	return 0;
}


while running i get those 2 exceptions:
https://postimg.org/image/d4mjruu01/
and
https://postimg.org/image/xejv6zv4x/
why?
Thanks!
Last edited on
Topic archived. No new replies allowed.