Results 1 to 2 of 2

Thread: Simple Winsock client/server file uploader demo.

  1. #1

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Simple Winsock client/server file uploader demo.

    Recently I've seen a few about questions sending data using Winsock across a network and a lot of the times people have trouble figuring out when their data has been fully sent/received or if there is more. TCP/IP being a streaming protocol, doesn't lend itself well to this. My answer is to implement your own scheme to do this over TCP/IP. It usually involves sending a length prefix along with the data so the receiver can count the bytes to determine when it has received all the data.

    The attached applications are a client application and a server application that can transfer a file between them. The client application sends the file and the server receives the file and saves it to a configurable location. I've set default values that should allow you to test the programs right away on the same machine using the loop back adapter.

    You must start both applications and click the "listen" button on the server and then you click the "connect" button on the client application and the status bars of both application should read "connected" if it succeeds. From there you click the "upload" button on the client application and select a file using the dialog that pops up. The client should begin the upload after selecting a file. I recommend using a large file to see the progress. Any file of 100 MB or more should be sufficient. The loopback and even LAN is very fast so small files will be transferred instantly.

    Note: These applications were created using Visual Studio 2010 so you would need that or later to open the projects.

    On last thing. The apps are not meant to be usable. They are made to demonstrate the basic idea behind creating your own protocols for data transfer. In an effort to keep it as simple as possible I didn't add too many complexities to it. The sever is limited to being able to accept one connection and there can only be one file transfer at a time. It cannot in its current state transfer multiple files at the same time. Also, I did not put too many error traps so expect that if you push it by doing weird things, it will crash.

    Feel free to ask any questions about it. Any suggestions to improve it will also be welcomed.
    Attached Files Attached Files
    Last edited by Niya; Aug 15th, 2013 at 01:27 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    527

    Re: Simple Winsock client/server file uploader demo.

    Deleted...

    I replied in the wrong thread!

    Sorry...
    Last edited by Alain; Jul 26th, 2014 at 12:38 PM.
    Don't ask why, just reboot!

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