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

The Archive Base Latest Questions

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

SOCKET lhSocket; int iResult; lhSocket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); char *sendbuf = this is a test;

  • 0

SOCKET lhSocket;
int iResult;
lhSocket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
char *sendbuf = “this is a test”;
iResult = send(lhSocket, sendbuf, (int)strlen(sendbuf), 0 );

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

I have client and Server program using sockets in C++ now i send a buffer it is received by server now when server acknowledge me back saying i got your packet i should get that in string format not bytes received : something. how to achieve that ?

My iresult returns me an integer value, I am sending a message over socket to server , i dont want to print it as Bytes sent : 14.
I want to print the message sent as string to server.
I am dealing with Sockets.
How i can achieve this in C++

  • 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-16T10:16:54+00:00Added an answer on May 16, 2026 at 10:16 am

    sendbuf is the string which you are sending. Print sendbuf instead:

    printf("Bytes Sent: %s\n", sendbuf);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example: // socket created above this int iSocketOption = 1; setsockopt(CFSocketGetNative(socket), SOL_SOCKET, SO_REUSEADDR, (void
From my client: send(socket, this is a buffer, ...); send(socket, second buffer, ...); From
This is my socket server with fork: #include <stdio.h> #include <string.h> #include <stdlib.h> #include
Both Network.Socket.ByteString and Network.Socket.ByteString.Lazy have a send function. Network.Socket.ByteString has a sendTo function, but
Will Socket.SendAsync always send all data in the byte[] buffer that the SocketAsyncEventArgs has
Can socket send / recv set errno 27 (EFBIG) on Solaris? Under which condition
This socket is not working, I tried everything but it never actually displays the
SOCKET server = socket(PF_INET,SOCK_STREAM, 0); bind(server, 7.7.7.7, sizeof(7.7.7.7) ); listen(server, 0); server.Poll(1, SelectMode.SelectRead); error
A socket client program establishes a connection with the server, writes some bytes and
I have socket already declared socket like this: serverAddr = InetAddress.getByName(this.ip); socket = new

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.