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 3302758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:53:09+00:00 2026-05-17T20:53:09+00:00

I am working on a project where a partner provides a service as socket

  • 0

I am working on a project where a partner provides a service as socket server. And I write client sockets to communicate with it. The communication is two way: I send a request to server and then receive a response from server.

The problem is that I send the data to the server but apparently the server cannot receive the data.

From my side I just use very simple implementation just like the example from http://www.linuxhowtos.org/C_C++/socket.htm

#include <sys/socket.h>

socket_connect();

construct_request_data();

send(socket, request_data, request_length, 0/*flag*/); // I set flag as 0

// now the server should receive my request and send response to me    

recv(socket, response_data, response_length, 0);   

socket_close();

And it seems that the server socket is implemented with a “binding” to std::iostream and it is buffered stream. (i.e. the socket send/recv is done in iostream::write/read.)

server_socket_io >> receive_data;

server_socket_io << response_data; 

Btw, I got a test client from my partner and it is wrapped in a iostream as well. The test socket client can communicate with the server without problem, but it must do iostream::flush() after every socket send.

But I want to just keep it simple not to wrap my socket client in iostream.

I just wonder whether the buffered iostream results in the problem: the data is not processed since the data the client socket sent is just in very small amount and still buffered.

Or could it be my problem? how can I know if I really send out the data? does my client socket also buffer the data?

I have tried some “bad” workaround with TCP_NODELAY but it didn’t help!

How can I solve the problem? from client side? or server side?
Should I close the socket after sending request and before receiving response, so that the data will be “flushed” and processed?

or should I wrap my socket in iostream and do flush?

or the server socket should use a “unbuffered” stream?

thanks for any suggestion and advice!

  • 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-17T20:53:10+00:00Added an answer on May 17, 2026 at 8:53 pm

    Further to Jay’s answer, you can try any network packet sniffer and check whether your packets are getting to the server or not. Have a look at wireshark or tcpdump.

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

Sidebar

Related Questions

I'm working on a Web Service project to provide data to a partner. Our
I am working with a partner on a project. He has written a lot
I am a computer science student and my project partner and I are working
I'm currently working with partner on a PHP project. We both edit directly to
For a project, I was working with a partner writing a decision tree implementation.
My partner and I are working on a project using TFS. For some reason
I'm working on a project of which a large part is server side software.
I have a working project that Im amending, it crashes after trying to use
I'm curious if it is possible to move the written and fully working project
While working a project tonight, I ended up using one .js resource file for

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.