I’ve the following function but i get invalid arguments error , can please
someone tell me where’s this invalid param or argument :
int Asio_Send_Pck(int iSendt,int Lsocket,char * Lbuff,int Len)
{
session* iTempSession = reinterpret_cast
On 12/07/2018 20:12, randy wrote:
I’ve the following function but i get invalid arguments error , can please someone tell me where’s this invalid param or argument :
Usage queries belong in the boost-users mailing list, not this one. You should also indicate the library in the subject, eg. [asio].
int Asio_Send_Pck(int iSendt,int Lsocket,char * Lbuff,int Len) { session* iTempSession = reinterpret_cast
(Lsocket);
This is poor design (and may be UB on some platforms). You should use a pimpl or opaque pointer instead. (Note that there are ways to do this even if you need to declare a pure C API.)
boost::asio::async_write(iTempSession->socket() , boost::asio::buffer(Lbuff, Len), boost::bind(&session::handle_write, iTempSession, boost::asio::placeholders::error, iTempSession->data, iSendt ));
There are lots of things that could be wrong with this. Since you haven't even posted the actual error you're getting or other details about objects referenced in this call it's hard to tell for sure. But at least one issue is that in order to conform to Asio's WriteHandler concept you need to include boost::asio::placeholders::bytes_transferred in your handler arguments. See https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/reference/WriteHan....
participants (2)
-
Gavin Lambert
-
randy