Boost logo

Boost Users :

Subject: Re: [Boost-users] boost asio tcp::socket assign
From: Lloyd (lloydkl.tech_at_[hidden])
Date: 2010-12-30 04:01:57


Thanks Igor,

then is there any method/operator (=) available in asio to assign a
socket to another socket?

Thanks a lot,
  Lloyd

On Thu, Dec 30, 2010 at 2:24 PM, Igor R <boost.lists_at_[hidden]> wrote:
>> I have a boost::asio::ip::tcp::socket variable (reference) in a class,
>> and it is initialized at the object construction time. At a later time
>> I need to assign a new socket to this "socket reference variable". I
>> think boost::assign is meant for that. But when I use assign, get the
>> following error... (or is there any other method available?)
>>
>>
>> .....cannot convert parameter 2 from 'boost::asio::ip::tcp::socket' to
>> 'const boost::asio::detail::win_iocp_socket_service<Protocol>::native_type
>> &'
>>
>>
>> The code snippet is as follows...
>>
>> class MyClass
>> {
>> ....
>> .....
>>  private:
>>         tcp::socket& Socket;
>> }
>>
>> void MyClass::SetSocket(tcp::socket& s)
>> {
>>        Socket.assign(boost::asio::ip::tcp::v4(),s);
>> }
>
>
> assign() sets a native socket handler to the tcp::socket object. I.e.
> if you open a socket by means of some native API, then you can
> assign() this native socket handle to tcp::socket.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net