Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7551451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:29:53+00:00 2026-05-30T10:29:53+00:00

I am writing a client-server application using sockets in C++. The protocol for communications

  • 0

I am writing a client-server application using sockets in C++.

The protocol for communications is essentially:

  1. The client connects to the server.
  2. The client “sends” an ASCII command to the server.
  3. The server executes the command remotely, and gets the results, and sends the results back to the client.

the results can be multiple megabytes of data. Once all the results are sent to the client, I would like the server to signal the client that it’s done.

Is the best way to closesocket(), or should it send a message that indicates to the client that there are no more results, and the client can decide whether to close the socket or not? The drawback with closing the socket is that the client will need to establish a new connection if it wants to execute another command, but the drawback of sending a message back from the server is that the client needs to scan every recv to determine if the results are done.

Which is the best practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:29:54+00:00Added an answer on May 30, 2026 at 10:29 am

    I would take a slightly lateral approach:

    • Client sends command to server
    • Server send size of response and then the real response
    • Client can issue new command / close connection

    In this way the client knows how much to read and can decide whether to close the connection or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a client-server application using TCP Sockets. The server is written in
I am writing a TCP server application using Winsock. The client that connects to
I'm writing a client-server app using BSD sockets. It needs to run in the
I'm using C to implement a client server application. The client sends info to
I'm writing a simple client/server application and I found that using DataInputStream to read
I am writing an application that communicates using sockets. I have a server running
I am writing a client-server application using Java-RMI. Some server-side ressources have to be
I'm writing single-page web application. Client interacts with server using AJAX retrieving quite complex
I'm writing a small (C#) client application that sends data using a TCP/IP connection
I'm writing a client application to communicate with a server program via UDP. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.