boost-asio

Boost Asio On Linux Not Using Epoll

I was under the impression that boost::asio would use an epoll setup by default instead of a select implementation, but after running some tests it looks like my setup is using select. OS: RHEL 4 Kernel:2.6 GCC:3.4.6 I wrote a little test program to verify which reactor header was being used, and it looks like its using the select reac...

boost::asio fails to close TCP connection cleanly.

I am trying to implement a simple HTTP server. I am able to send the HTTP response to clients but the issue is that on Firefox I get "Connection Reset" error. IE too fails, while Chrome works perfectly and displays the HTML I sent in the response. If I telnet to my server then I get "Connection Lost" message, just after the response. So...

Why does boost::asio appear to do nothing.

I'm trying to implement the irc protocol in a very basic manner. My first attempt is to use boost::asio and connect to a server and read the motd. AFAIK the motd is sent to every client when they connect. I have made the following test program and it seems to not do anything. It's not a very good piece of code but this is all I have afte...

reading in C++ a socket open by Java + structure alignment

Hi All I am trying to write in Linnux a client in C++ using boost::asio data from a socket. The server is built in Java. The issue I have now is that I cannot read correctly some piece of information from the socket. If the client is done in JAVA everything is ok. In details the big error I have are in receiving the unsigned long and t...

Server abort when client tries to reconnect

I have a c# client talking to a C++ TCP Server on Linux using boost. The client is able to send/rcv messages from the server but when I close the client and restart it again, the server abort. I am new to boost so any help would be great. Below is the code of my server. void TcpServer::handle_accept(Client* new_client, const boost::sys...

resolve function does't work in boost/asio

I am learning boost/asio and writing example program which was in e-book. of course it didn't work ;) #include <boost/asio.hpp> #include <iostream> int main () { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver::query query("www.boost.org", "http"); boost::asio::ip::tcp::resolver::iterator destination = boost...

What is the difference between tcp::endpoint and udp::endpoint in Boost::Asio?

It seems boost::asio defines a separate endpoint class for each protocol, which is irritating if you want to perform both UDP and TCP operations on a particular endpoint (have to convert from one to the other). I'd always just thought of an endpoint as an IP address (v4 or v6) and the port number, regardless of TCP or UDP. Are there sign...

boost::asio udp - How do I get many mutable buffers filled?

I'm trying to receive many udp messages from one async_receive call. My messages are approx. 60 bytes long. I'm giving an async_receive call a buffer array very similar to the boost docs but can't seem to get all the buffers filled. char d1[128]; char d2[128]; char d3[128]; boost::array bufs = { boost::asio::buffer(d1), boos...

boost::asio hangs in resolver service destructor after throwing out of io_service::run()

I'm using a fairly simple boost::asio set-up, where I call io_service.run() from the main thread. I have a tcp resolver, and use async resolve to look up an address. When that look-up fails, I throw an exception inside the asynchronous callback. I catch this exception outside the run() call, inside the main function. I then call stop() o...

C++ boost/asio client doesn't connect to server.

I am learning boost/asio ad wrote 2 programs(client and server) from e-book with minor changes. Basically it should connect to my server. When i try to connect to outside world(some random http server ) all is good and it works but when i change destination to "localhost:40002" it says invalid argument. client code: #include <boost/asi...

Accurate continuous timer callback

Ive got an application where I want to display a frame every x milliseconds. Previously I did it like this: class SomeClass { boost::thread thread_; boost::timer timer_; public: SomeClass() : thread_([=]{Display();}) { } void Display { double wait = 1.0/fps*1000.0; while(isRunning_...

How to flush the socket using boost

I am implementing a server that sends xml to clients using boost. The problem I am facing is that the buffer doesn't get sent immediately and accumulates to a point then sends the whole thing. This cause a problem on my client side, when it parses the xml, it may have incomplete xml tag (incomplete message). Is there a way in boost to...

What is the advantage of using the mutable buffer objects in boost ASIO compared to char arrays?

I'm designing/developing a UDP server application and plan to use boost. What are the mutable buffer objects for and what advantage is it over an standard char array? ...

Setting TTL on outgoing ICMP packets?

Hi, I have been trying to set the TTL on ICMP packets using the boost::asio::ip::unicast::hops option (using Boost 1.43) and then reading it out with get_option. get_option gets 1 regardless what I use in set_option. And when inspecting the packets sent using wireshark, the TTL is 128. Am I missing something here? Should I use another ...

How can I pass the source IP in a UDP server using Boost ASIO

I need to get the source IP for a datagram in a UDP server I'm writing using boost ASIO. In the example udp datagram server the line: Note: my current code is identical to the existing udp async server example in the boost asio documentation. socket_.async_receive_from( boost::asio::buffer(data_, max_length), sender_endpoint_...

Is it more efficient to use boost::asio::basic_stream_socket::async_read_some instead of boost::asio::async_read?

Is it better to use boost::asio::basic_stream_socket::async_read_some instead of boost::asio::async_read when it comes to high performance data throughput? ...

Trying to replace my boost::asio::read with boost::asio::async_read

So, the code I started with and which works (with important caveats below) int reply_length = boost::asio::read(*m_socketptr, boost::asio::buffer((char*)reply, 6)); This works, I get the header which I then decode and follow up with another read which gets me my message and then I loop back to the top and read another header. This pe...

Assign in Boost::Asio::Stream_Handle calling convetion crash

I am trying to create a Stream_Handle for a harddisk device. Here is the piece of code. ntStatus = NtCreateFile(source, DesiredAccess, &oa, &ios, NULL, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, NULL, 0); //Create ReadStream boost::asio::io_service io_service; boost::asio::windows::stream_handle...

problem with some boost asio code

Ultimately I'm trying to transfer buffers from one machine to another. The code below takes stream of <id><size><data with size bytes> and reads the part in the handleReadHeader function, then reads the <size> number of bytes, then goes back and waits for another <id><size> pair. I've pasted a lot of code, but really the only functions...

preventing boost from making a copy of a my callback handler

I wrote a small tcp client using boost::asio, providing the following function: typedef boost::function<void(const bs::error_code& errCode, size_t bytesTransferred)> ReadHandler; void CTcpClient::AsyncRead2(std::vector<char>& data, size_t length, ReadHandler readCompletedCallback) { async_read(m_tcpData->socket, ba::buffer(data, le...