Sign in to follow this  
Followers 0
Radiance

Managing TCP in a Multi-Client Server

1 post in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0