Results 1 to 2 of 2

Thread: a bit of a dilema with many sockets, threads, windows messages, and MFC

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    241

    a bit of a dilema with many sockets, threads, windows messages, and MFC

    I'm making a network analyzer / Administration tool and one of the features that im working on is a port scanner. Im tryin to make it really fast so i made a thread and my own CMySock class derived from CAsyncSocket. In the thread i declare a large array of these sockets and then have a loop in which they all try to connect to their assigned port. Then when they do connect the OnConnect function is called. The main problem is that the OnConnect functions are not being called for the sockets until the loop ends. And only if I put a MessageBox at the end of the loop before the end of the thread, if i do not put the messagebox there then the thread will return and the sockets will go out of scope. However it works fine if i put a messagebox in the loop except i obviously cant do this. It seems like the main problem is that the loop doesnt allow time for windows to process the messages. Is there any way i can make it so that the loop allows time for windows to process all of the messages?

    Thx in advance.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    241
    i think i fixed it, i put in my own little message processor in the loop

    if peekmessage
    translatemessage
    dispatchmessage

    is this a bad way to do it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width