Sunday, July 29, 2012 4:24 AM
i have a simple application for receiving data from socket.
i have a class based on CAsyncSocket that i override a function for its OnReceive function. when the OnReceive Event raised i go and get the data.
my hardware is a board that produces counter and sends data by network. when i want to receive data, the data is missed. (i find this miss by checking counter after receive). the board generates and sends the data and i should receive it concurrently.
but when i play with the GUI, for example by clicking the title bar , the miss of data, begins.
i tried to do my receive in a thread in order to remove its dependency to gui, but i don't achieve any gain in data receiving.
is there any suggestion???
- Edited by Moharram.B Sunday, July 29, 2012 4:27 AM
Sunday, July 29, 2012 12:21 PM
Assuming that you are using SOCK_STREAM, Windows does not lose the received network data.
It saves it in internal winsock buffers until you call Receive, then it gives you the saved data. Make sure you properly account for the number of bytes count that is returned by the Receive call. It can give you more than one message at a time!
- Marked As Answer by Helen ZhaoModerator Monday, August 06, 2012 2:25 AM
Saturday, August 11, 2012 9:50 AM
i found a sample in WDK about WSK (WinSock Kernel).
this sample creates a server socket in kernel that echos any data it receives.
whould i get a better performance in Kernel ???
also, my app should be client, but there is no sample about client in WDK?
Saturday, August 11, 2012 1:54 PM
The winsock operations already reside in the kernel, so I doubt that putting your receive processing in the kernel would accomplish much. Presumably, you would still have to pass the received data out of kernel to the application level, but winsock already does that for you.
Putting your socket code in a thread will make it independent of GUI processing. And you could use the SetThreadPriority API to give your socket thread higher priority than your GUI thread. What problem did you have when you tried using a thread?