I'm building a client/server application to make periodic backups of certain files. Basically, the client will monitor certain files for changes, and upload them to the server. The server will then receive them and will save them with an incrementing postfix.(i.e. "filename_v1
", "filename_v2
", etc). Now, I managed to get most of it done, but some issues arose and I could not find anything related to them.
Before I begin, please note that:
- I did my best to find a solution on my own.
- I followed (and completed) several socket programming tutorials.
- I don't know anybody with c# and/or socket programming experience.
Here's the logic:
- Server starts up, begins to listen. (BeginAccept)
- When a client connects, a "worker" socket is created.
- Worker socket begins receiving. (BeginReceive) / Client sends a file ( SendFile )
- When data is received, file is saved. (also checking for earlier versions, but it's irrelevant here.)
- goto 3.(we need to receive more files from the same client.)
steps 1-4 work just fine.
Here's the problem: in step 5, even though server receives nothing, onDataReceive(the callback method) is called, and the server finds itself in an infinite loop. I tried to close (or disconnect) the worker socket, but no chance there. I'm beginning to suspect that maybe my algorithm is a bit sloppy.
Anyway, any comments, suggestions or help is highly appreciated.