mirror of
https://github.com/boostorg/asio.git
synced 2026-01-28 06:42:08 +00:00
........ r49155 | nmusatti | 2008-10-07 08:46:14 +1100 (Tue, 07 Oct 2008) | 1 line Patch from Ticket #2372 ........ r49195 | chris_kohlhoff | 2008-10-09 17:22:58 +1100 (Thu, 09 Oct 2008) | 2 lines Add missing bounds checks as specified in TR2 proposal. ........ r49197 | chris_kohlhoff | 2008-10-09 17:28:39 +1100 (Thu, 09 Oct 2008) | 2 lines Merge codegear changes from non-boost version of asio. ........ r49198 | chris_kohlhoff | 2008-10-09 17:30:16 +1100 (Thu, 09 Oct 2008) | 4 lines Ensure the streambuf's egptr() is kept in sync the pptr(). Use std::memmove rather than std::rotate to minimise data copying. Avoid unnecessary resizes of the underlying vector. ........ r49199 | chris_kohlhoff | 2008-10-09 17:31:01 +1100 (Thu, 09 Oct 2008) | 3 lines Fix basic_socket_streambuf to work with Protocol objects that don't provide a resolver. ........ r49200 | chris_kohlhoff | 2008-10-09 17:32:00 +1100 (Thu, 09 Oct 2008) | 2 lines Add example showing use of local::stream_protocol::iostream. ........ r49201 | chris_kohlhoff | 2008-10-09 17:33:34 +1100 (Thu, 09 Oct 2008) | 4 lines Only use TerminateThread when explicitly requested by the user by calling asio::detail::thread::set_terminate_threads(true). This fixes a memory leak that may occur with internally created threads. ........ r49202 | chris_kohlhoff | 2008-10-09 17:34:48 +1100 (Thu, 09 Oct 2008) | 3 lines Make the service_registry's usage of typeid work when the default gcc linker visibility is set to hidden. ........ r49203 | chris_kohlhoff | 2008-10-09 17:39:05 +1100 (Thu, 09 Oct 2008) | 2 lines Reduce memory usage by doing lazy initialisation of the io_service's reactor. ........ [SVN r49221]
60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
//
|
|
// stream_client.cpp
|
|
// ~~~~~~~~~~~~~~~~~
|
|
//
|
|
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
#include <cstring>
|
|
#include <iostream>
|
|
#include <boost/asio.hpp>
|
|
|
|
#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|
|
|
|
using boost::asio::local::stream_protocol;
|
|
|
|
enum { max_length = 1024 };
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
try
|
|
{
|
|
if (argc != 2)
|
|
{
|
|
std::cerr << "Usage: iostream_client <file>\n";
|
|
return 1;
|
|
}
|
|
|
|
boost::asio::io_service io_service;
|
|
|
|
stream_protocol::endpoint ep(argv[1]);
|
|
stream_protocol::iostream s(ep);
|
|
|
|
using namespace std; // For strlen.
|
|
std::cout << "Enter message: ";
|
|
char request[max_length];
|
|
std::cin.getline(request, max_length);
|
|
size_t length = strlen(request);
|
|
s << request;
|
|
|
|
char reply[max_length];
|
|
s.read(reply, length);
|
|
std::cout << "Reply is: ";
|
|
std::cout.write(reply, length);
|
|
std::cout << "\n";
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cerr << "Exception: " << e.what() << "\n";
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
#else // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|
|
# error Local sockets not available on this platform.
|
|
#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|