Reputation: 5019
SOCKET sock = generate_socket("fileWizard");
notifier = new QSocketNotifier(sock, QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activate(int)), this, some_slot(int));
The SOCKET is a win32 SOCKET, the function of "generate_socket" is creating a socket connect to a local exe which called "fileWizard"(don't know the implementation details of the function generate_socket). With Qt, we always generate the socket and connect the signal and slot, but can't find a similar example in asio.
Do not familiar to socket and asio yet, please tell me what information you need. Thanks
Edit :
The purposes of the codes are monitoring the SOCKET, if there are any change of it, it will call the call back.
Similar to the example of asio(Daytime.3 - An asynchronous TCP daytime server) The part which make me confuse is
1 : How could I transform the SOCKET to one of the boost::asio socket?
2 : How could I monitor the "change"(anything can read) of the socket(our seniors called it file descriptor)?By read_async?
Upvotes: 0
Views: 478
Reputation: 51911
basic_stream_socket
on top of an existing native socket, such as a Windows SOCKET
.QSocketNotifier
class, Boost.Asio does supports reactor-style operations by using null_buffers()
. Both approaches allow the application to be notified when an event occurs, such as when data is ready to be read from a file descriptor. This event notification capability allows for each event loop to integrate with other event loops or third-party libraries. For a complete example that uses null_buffers()
, see the official Boost.Asio non-blocking example.Upvotes: 1