Hello,

I am currently trying to use boost asio for IPC. I ran into 2 strange issues:

1) when using the acceptor class, when I bring my process up, I get the error 'Already open' when trying to listen. The port I am trying to bind to is definitely not being used by another process. This only happens for a couple of my processes (others work fine).

2) when trying to establish a connection to a server (one that works fine from above), both processes receive the connection (and also disconnection when I kill one), but when I try to write to the socket, I get the error 'Bad File Descriptor'. BeforeI write, I also am checking _socket->is_open(). This also happens when I try writing IMMEDIATELY after connect().

These issues smell to me like I have failed to clean up resources somewhere, but I went back over my code and am calling close() whenever I am done with a socket (also, after the process dies, shouldn't they be cleaned up anyway? So I am not sure why issue 1) would occur).

HOWEVER, I do NOT experience any of these issues on my local machine. If I run in my vbox (Linux CentOS 32-bit), everything works fine and dandy. This only happens when I run on another server (Linux CentOS 64-bit). I assure you I am doing a fresh compile anyway when I run on either machine.

Is there some difference in the way the sockets are being cleaned up on 32-bit and 64-bit machines? Or is there a machine setting somewhere?

Another thing I notice is that in Boost IPC, there is no 'Localhost'. So on my 32-bit vbox I am connecting to '127.0.0.1'. The remote server supports IPv4 and IPv6 so I also try connecting to '::1' which has the same wierd behavior.

I am by no means an expert on TCP, but any help or further information would be greatly appreciated!

Thank you and have a great day!

Recommended Answers

All 3 Replies

Also, if it helps, I am using one single boost::asio::io_service object for all connections... I have a Connector and an Acceptor class that handles these connections. When a new connection occurs, I create a Reader object and pass a pointer to the socket and spawn a new thread to read incoming messages.

Both servers I mentioned above have 2 processors allocated to them as well.

can you post your code here if you dont mind.?
we need to read through your code.... possibly run it ourselves ok

Hi richieking. I ended up just implementing my own anyway. I have a feeling it had to do with Boost compatability with the machine settings on the one server. My implementation is working as expected now.

Thank you for your time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.