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

  • Home
  • SEARCH
  • 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 9254857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:34:44+00:00 2026-06-18T11:34:44+00:00

I need to send multiple request (command) to server at port 55005. My first

  • 0

I need to send multiple request (command) to server at port 55005.
My first request get process successfully & I received out put also.
But for second request it gives error (WSAESHUTDOWN – Error 10058).
After first request I call
shutdown(ConnectSocket, SD_SEND);
Then only server process the first request & send me output.
Now can re-open socket processing next request ?**

How I can process multiple request after shutdown(ConnectSocket, SD_SEND) ?
Thanks in Advance for your suggestions.

I send the first request , wait for first reply. After first request reply, I can send next request. This is business logic requirement. I don’t want to open a new connection for each request.

Snapshot Code start here —————->

**//This for loop will send multiple request to Servers.**
for(it = CommandList.begin(); it != CommandList.end() ; it++ )
{
    //get each command request & send it to server.
    std::string  sendBuf; // =  (*it);
     sendBuf= *it;
    int length = (int)strlen(sendBuf.c_str());
    //----------------------
    // Send an initial buffer
    iResult = send( ConnectSocket, (char*)sendBuf.c_str(), length, 0 );
    if (iResult == SOCKET_ERROR) {
        wprintf(L"send failed with error: %d\n", WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
    }

    printf("Bytes Sent: %d\n", iResult);


    // shutdown the connection since no more data will be sent
    iResult = shutdown(ConnectSocket, SD_SEND);
    if (iResult == SOCKET_ERROR) {
        wprintf(L"shutdown failed with error: %d\n", WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
    }

    // Receive until the peer closes the connection
    do {

        iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
        if ( iResult > 0 )
            wprintf(L"Bytes received: %d\n", iResult);
        else if ( iResult == 0 )
            wprintf(L"Connection closed\n");
        else
            wprintf(L"recv failed with error: %d\n", WSAGetLastError());

    } while( iResult > 0 );
}
  • 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-06-18T11:34:46+00:00Added an answer on June 18, 2026 at 11:34 am

    As Joachim said, don’t call shutdown until you are done with the connection. This TCP socket is a “stream”… stuff can go back and forth at will. You as a programmer have to determine where “requests” and “responses” begin and end… don’t use shutdown for that.

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

Sidebar

Related Questions

I am making a command line application. I need to send out multiple POST
The situation is I have multiple webservices for which I need send request and
I am new to socket programming. Need to send multiple strings one-by-one to server
I need send certain attributes(say, human readable user name) from server to client after
Is there a way, server-side using .NET, to send multiple custom events to Google
I need to send multiple messages between a native named pipe and a System.IO
I'm currently creating a search form which will send a request to the server
So for my Android app I need a centralized server so multiple phones can
I'm potentially looking to send out a packet, or some kind of request across
I am uploading multiple files using AFNetworking. I need to send extra information such

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.