CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2000
    Location
    High on a hill in the Ohio valley
    Posts
    711

    Threads and socket connections

    I have a basic dialog program that connects to another computer over the internet to retrieve some files (small) using a CSocket connection.

    It does this repeatedly about every second or 2 for a limited amount of time.

    What I am noticing is that the program hangs, or locks up momentarily sometimes during this. Example: moving the mouse over the dialog stops and starts.

    Seems like the sending and receiving is stopping the rest of the program.

    Is it possible to put sends and receives in a thread ? If so, is there an example of this somewhere?

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Moved thread]

  3. #3
    Join Date
    Feb 2004
    Posts
    21
    It is normal when you've put recv() function in your main thread to block everything untill the file is downloading(If you want to know why read in MSDN or Network Programming for Microsoft Windows-very good book).
    Check the functions _beginthread() and _endthread() in process.h or afxBeginThread() if you use MFC.
    Last edited by defiler_z; March 11th, 2004 at 04:09 PM.

  4. #4
    Join Date
    Aug 2000
    Location
    High on a hill in the Ohio valley
    Posts
    711

    ok

    thanks, I'll check those.

  5. #5
    Join Date
    Jul 2005
    Location
    India
    Posts
    238

    Angry Re: Threads and socket connections

    i m working in VS 6.0 C++. non mfc
    trying to create the thread using
    Code:
    _beginthread(func,0,NULL);
    but i m getting error
    error C2065: '_beginthread' : undeclared identifier

    i had linked to MSVCRT.LIB and using process.h but still getting this error
    what can be the possible cause????

    Virender
    Virender Chauhan
    INDIA
    ---------------------
    RATE THE POST IF I HELPED YOU

  6. #6
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    1,194

    Re: Threads and socket connections

    You can also use CreateThread()
    Please don't forget to rate users who helped you!

  7. #7
    Join Date
    Jul 2005
    Location
    India
    Posts
    238

    Re: Threads and socket connections

    working on C++....
    Virender Chauhan
    INDIA
    ---------------------
    RATE THE POST IF I HELPED YOU

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