"Address incompatible with the requested protocol" error when creating a new boost socket

259 views
Skip to first unread message

D Williams

unread,
Jan 2, 2014, 2:41:01 PM1/2/14
to automat...@googlegroups.com
Hello,
I am trying in to add another socket to my program that is already running openDNP3. however when I create another boost connection acceptor, the openDNP3 errors saying "An address incompatible with the requested protocol was used" is it possible to create another acceptor while running the openDNP3? If so how can it be done?
Thanks
DW

J Adam Crain

unread,
Jan 2, 2014, 2:45:27 PM1/2/14
to automat...@googlegroups.com
It's not possible on the same port. This limitation will be removed in the near future.

For the time being, the only way to run two separate outstation connections is to use different ports.

D Williams

unread,
Jan 2, 2014, 3:00:15 PM1/2/14
to automat...@googlegroups.com
Hello Adam,
Thank for the information, this is very good to know for another project I am working on. However, I am trying to create another boost accepter independent of the openDNP3 and when I do this, the openDNP3 accepter gives that error. any idea why that might occur?
Regards,
DW

J Adam Crain

unread,
Jan 2, 2014, 3:03:32 PM1/2/14
to automat...@googlegroups.com
Ah, I see.

Perhaps a conflict between IPv6 / IPv4? Are you using the opendnp3 code as a template?

Here's how we set up the acceptor:


See any differences between this and your other program?

D Williams

unread,
Jan 2, 2014, 4:35:32 PM1/2/14
to automat...@googlegroups.com
Hello Adam,
my code is a little different from the opendnp3 but not by much.

I try doing it the same way opendnp3 does, and I get read violation in win_iocp_socket_service_base.ipp @ iocp.service_.work_started();
would you have any idea why it would do this?

attached is a sample of the code I am using, I inserted this cod directly in to the main of the c++ outstation demos main :

boost::asio::io_service* m_IoService; // io service

boost::asio::strand* m_Strand;; // strand

boost::asio::ip::tcp::acceptor* m_Acceptor; // connection acceptor

boost::asio::ip::tcp::socket* m_Socket; // connection acceptor

boost::asio::ip::tcp::endpoint* m_Endpoint; // endpoint

m_Endpoint = new boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 22222);

m_IoService = new boost::asio::io_service(); // io service

m_Socket = new boost::asio::ip::tcp::socket(*m_IoService);

m_Strand = new boost::asio::strand(*m_IoService);

try

{

// original

//m_Acceptor = new boost::asio::ip::tcp::acceptor(*m_IoService, *m_Endpoint);

// moded form opendnp3

m_Acceptor = new boost::asio::ip::tcp::acceptor(*m_IoService);

m_Acceptor->async_accept( *m_Socket,

*m_Endpoint,

m_Strand->wrap([](const boost::system::error_code& code){

HandleConnect1(code);

}));

}

catch(...)

{

}

Regards,
DW

J Adam Crain

unread,
Jan 2, 2014, 4:42:28 PM1/2/14
to automat...@googlegroups.com
I think for the purposes of learning ASIO, you are better off with the ASIO docs and the ASIO support list:


Opendnp3 uses ASIO in very specific ways that may not be necessary for your program.

For instance, there's no need for the "strand" in single threaded ASIO program.

-Adam

D Williams

unread,
Jan 2, 2014, 5:08:42 PM1/2/14
to automat...@googlegroups.com
Hello Adam,

I am familiar with ASIO, the code snip in the last replay was merely to try and investigate the problems without the rest of my code, using the same methods done in the opendnp3 code you sent me. I only find this problem when the opendnp3 outstation is running. if I try it with without the opendnp3 I do not have this problem.

I will try the ASIO support list.

Thank you.
Best Regards,
DW

J Adam Crain

unread,
Jan 2, 2014, 7:47:33 PM1/2/14
to automat...@googlegroups.com
That is indeed a strange behavior.  Opendnp3 can create tons of acceptors in parallel for outstations.  I've had it up to over 1000 concurrent master/outstations connection pairs.  I'm really not sure what would cause this error.

-Adam
Reply all
Reply to author
Forward
0 new messages