Varnius 2 Newbie Poster

I started learning Winsock (2.2) programming in university recently and when writing my first program (fileserver and its client) a few questions came to mind. Let`s assume my fileserver is continuously listening for client connections and when one occurs it establishes connection, does whatever client wants (such things as list directory contents, file upload or download, etc) then closes connection and again, listens for new incoming connections. Client waits for user input and connects to the server ONLY after receiving it. So, is this kind of thing right? Maybe the connection between client and server should not be terminated after each command but instead exist as long as client is open in remote computer. This way accept() and disconnect() would only be called once and things may speed up a bit. I don`t know if there is a way to keep "empty" connection alive, though.

Any thoughts? :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.