Jump to content

Managing TCP in a Multi-Client Server


Recommended Posts

I need to write a TCP multiclient server. There's one main loop which checks for new connections and gives simple one-word responses to clients who make requests.

While 1
    Sleep(50)

    _ProcessTCPRequestsFromAllConnectedClients()
       
    $Socket = ""
    $Socket = TCPAccept($MainSocket)
    If $Socket = -1 Then ContinueLoop
    _RegisterNewUser($Socket)
WEnd

Client asks: What time is it?
Server responds: 10:41 am

The responses need to be sent as fast as possible.
Let's say a client with an older version connects and I want to send im an updated .exe which has 5 MB in size.

How would I go about sending that file to the client without slowing down the main loop too much?

The filetransfer doesn't need to be very speedy, can take as long as needed.

Any ideas welcome.

Edited by Radiance
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...