CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 21

Threaded View

  1. #1
    Join Date
    May 2007
    Posts
    127

    Question Single socket, more than one socket, multithreading?

    Hello! I want to make an app (for personal use) with this functionality (I'm using MFC):
    1. Send the screen of one computer to another;
    2. Send only a window from one computer to another (using PrintWindow function);
    3. Capture the webcam and send it to, again, another computer.
    (all 3 in the same time)

    I think there are 3 solution to do this:
    1. Use just one socket: record the screen, window and webcam in one thread and send it through one socket (problem: must wait to receive the screen in order to get the webcam: "received data: ahh... the screen, ok... another data... the screen again?" what I want to say is that if the screen manage to send itself more than 2 frames before the webcam I must wait to the screen).
    2. Use multiple socket?! I declare 3 socket variables: one for each connection (screen, window, webcam)? This means I must listen on 3 different ports on the server? (I don't like more than one port).
    3. Multithreading? Ok... use 3 different threads: one (the main) to capture the desktop and send it over the net, one for window and one for webcam. But, using the same socket to send data or diferent socket?

    One question: is multithreading usefull on the server? The user will not interact with the server more than make him listen. I've read that multithreading is helpfull when you want to make your UI more responsive. (should I capture all 3 things in one thread?).
    What about the client side? Should I have 3 separate thread?

    One way:
    On the client side I declare 3 socket variables. The main socket will connect the app and will handle the receiving of data from the screen; the other 2: the window and the webcam. No need for multithreading, right? The client will not make any intense calculation: just receive and display and I think there is no need for multithreading.
    But, how do I connect with 3 socket on the server with only one port? I think I must create a main socket on the server that will listen for connections and will handle screen capture. When the client want to get data from the webcam (or a window) the app will connect to the server with another socket and the server will create a separate thread for this request and another socket for connection.
    But how I do this? How I know on the server which kind of thread should I create: is for a webcam or window capture? How I know that the request is not from another client. All I have is the OnAccept event.

    I hope you understand what I've said. Please help me! My time to do this project is running out!
    Bye!
    Last edited by Chirieac; May 13th, 2008 at 03:46 AM.
    I love this forum. Thanks all for your help!

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

Featured