Click to See Complete Forum and Search --> : Threads and socket connections


alan93
March 11th, 2004, 01:29 PM
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?

Andreas Masur
March 11th, 2004, 01:40 PM
[Moved thread]

defiler_z
March 11th, 2004, 04:06 PM
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.

alan93
March 11th, 2004, 04:09 PM
thanks, I'll check those.

vc185002
February 18th, 2006, 05:29 AM
i m working in VS 6.0 C++. non mfc
trying to create the thread using

_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

philkr
February 18th, 2006, 06:59 AM
You can also use CreateThread() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp)

vc185002
February 20th, 2006, 08:15 AM
working on C++....