Re: Looking for information on MFC TCP Communication



Joseph M. Newcomer wrote:
> Note that to use the MFC socket classes the separate threads must be UI threads, although
> there is rarely a need to use separate threads. Note that separate threads must not
> manipulate any windows owned by the GUI thread. Other than the obvious of using a UI
> thread instead of a worker thread, providing appropriate synchronization for shared
> objects, and not touching the GUI, there are no "thread issues". Synchronization and the
> GUI interactions are fundamental to ALL threading and not unique to sockets, and the UI
> thread is documented, so it isn't really an "issue".
> joe
Got the 'don't touch the GUI' part down. One part I don't understand is
why it needs a UI thread.

Do the notifications of received data and etc require a queue in order
to properly route to the CAsyncSocket? If so, is there anything I need
to do beyond just the using the UI thread to ensure that the
CAsyncSocket gets it's notifications? (Adding message handlers?)

The reason I thought about seperate threads was that I was just going
to have the sending thread block when there was no information to send
(using a constant loop with a queue system). Since the UI thread would
have a handler and a non-blocking socket, I can definately try to
consolidate them into one.


Ok, one more quick question. I'm going to have to have a buffer for
each image before I transmit it across the network. Normally, I'd just
allocate the buffer , but this may be allocating / deleting alot of
space for just a short period of use. Do you think that it might be
worth looking into using pools of Image Buffer objects rather than
new/delete-ing them on the spot? Allocation tends to be a big part of
my resource chokes, and using the pool method might help alliviate it,
but never used it before. Granted, I'm going to try it without and see
if it's necessary first, but I was just looking for any comments if you
guys have used it before.

Thanks again,
Josh McFarlane

.



Relevant Pages

  • Re: tcp connection in gui: event based
    ... Write a small proc that does the accept and sets the connection to ... Use to register procs that get fired when the socket is ... If you have a full line, send it to the GUI, maybe dispatching via ... after to not block the event loop if its a bit bigger ...
    (comp.lang.tcl)
  • Re: Using too many threads?
    ... - Only the main window thread may update the main window GUI. ... Only the details window thread may update the details GUI. ... Is it safe for multiple threads to be reading/writing the same socket? ... "connection controller" thread per connection: ...
    (comp.os.os2.programmer.misc)
  • Re: Cant display Java gui
    ... and pop up the GUI when it receives one. ... >>and returns the decision to your C program via the socket. ... Thanks, Rogan! ... Please respond to "nntp AT dawes DOT za DOT net" ...
    (comp.lang.java.programmer)
  • Re: Too many Post Messages causing app not to refresh
    ... When I had async network ports with well over 100 concurrent connections, ... async sockets in separate threads, so that its GUI was not swamped. ... messages required any GUI updating; most went to a database directly. ...
    (microsoft.public.vc.mfc)
  • Re: Cant display Java gui
    ... Have the GUI listen on a localhost socket for a ... and pop up the GUI when it receives one. ... > It also means that you can properly queue the emails for the operator's ... Thanks, Rogan! ...
    (comp.lang.java.programmer)