Boost::asio::socket how to get int or uint from it that would be crossplatformly assignable back?
So we have some function like this:
void SendData (/* what goes here if we can only 开发者_运维问答send to our function C POD types like int, uint etc? */ socket, std::string message)
{
boost::asio::io_service ioserv;
boost::asio::ip::tcp::socket s(ioserv);
s.assign(boost::asio::ip::tcp::v4(), socket);
s.send(boost::asio::buffer(message));
}
and from some other function we want to call SendData
having some boost::asio::ip::tcp::socket sock
... so something like:
//...
SendData(/* what goes here? Is there any sock.getInt() */, "message");
//...
So what are my options for this? What simple C POD types can be taken from boost::asio::ip::tcp::socket that could be later reinterpreted with .assign
?
What simple C POD types can be taken from
boost::asio::ip::tcp::socket
that could be later reinterpreted withassign()
?
socket::native()
returns the native representation of what was passed to socket::assign()
. On Linux and Mac OS X this is an integer, I don't know about Windows.
精彩评论