elektrobank
Member
- Joined
- Aug 11, 2008
- Messages
- 19
- Programming Experience
- 10+
I am creating a simple server application that will listen for incoming mouse coordinates and then move the mouse accordingly. So basically it's like a very simple VNC server without the screen display. I have this basic part working. The problem is that response time is really bad. It seems like the server is not receiving the data fast enough to be able to move the mouse so that it appears to be in sync with the movement on the client machine. I'm using a buffer size of 32, and just sending my commands from the client as the same length every time so that I'm processing them as fast as they are sent. When they come in, I add them to a queue, then have a separate thread that processes the movement in the queue. I figured this was the fastest way, but it doesn't seem to be fast enough. Clearly there is a better way of doing this that I'm not seeing. Any suggestions?
My code looks something like this:
My code looks something like this:
VB.NET:
Public Sub dataArrival(ByVal ar As IAsyncResult)
Dim bytesRead As Integer = handler.EndReceive(ar)
If bytesRead > 0 Then
content = Encoding.ASCII.GetString(state.buffer, 0,
bytesRead)
eventQueue.Add(content)
handler.BeginReceive(state.buffer, 0,
StateObject.BufferSize, 0, New AsyncCallback(AddressOf dataArrival),
state)
end if
end sub