Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

get network interrupt

I'm trying to make an application in VC++, for receiving and writting data through network (Socket). Receiving is already working, but it is working  so, that the application is running in endless while loop. But I would like to make it so, that I will activate receive function only when network controller will receive something. So something like interrupt.

How can I do this?

Thanks
0
sasabunetic
Asked:
sasabunetic
1 Solution
 
jhanceCommented:
The BEST way to do this in Windows/MFC is to use the CAsyncSocket class.  When you derive a class of your own from CAsyncSocket you can override the OnReceive() handler which will then get called when you have incoming data.
0
 
jrocnuckCommented:
how about with select calls?

do a select in a separate thread on the read file descriptor, when the select returns if the code tells you there is something to be read, post a message back to your application telling your program to read.

Basically that's what the MFC socket class has built for you, but you have to be careful when using the MFC socket when it comes to multiple threads.

if you have a simple application with a simple socket, then MFC would be the easiest way to do this.
0
 
GloomyFriarCommented:
But select is not an "interrupt".
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now