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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:24:54+00:00 2026-05-23T20:24:54+00:00

I am working with sockets in C (linux) and I need to send a

  • 0

I am working with sockets in C (linux) and I need to send a bit longer text (60characters) over the network. I’ve tried a char pointer, but it is too short. Any suggestions what should I use?

char *data = "A lot of text....";
...
if (send(new_fd, data, 13, 0) == -1)
            perror("send");

I’m not really a c person, so what does that number 13 mean?

  • 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-23T20:24:55+00:00Added an answer on May 23, 2026 at 8:24 pm

    This is how you should send the data.

    char *data = "A lot of text....";
    ssize_t rc;
    ...
    rc = send(new_fd, data, strlen(data), 0);
    /* Check rc. */
    

    From the manual:

    ssize_t send(int socket, const void *buffer, size_t length, int flags);
    

    So the 13 is the number of bytes sent.

    One thing to consider is that send(2) doesn’t guarantee it will be able to send all of it in one go. You need to loop and check how much it wrote. A good way to do it is using the writen function of Stevens.

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

Sidebar

Related Questions

I'm working on an old school linux variant (QNX to be exact) and need
I am working on building an embedded network appliance (linux based) and have come
Over the last couple of months I've been working on some implementations of sockets
I have had no trouble getting the sockets working with localips, but once I
I have very little experience working with sockets and multithreaded programming so to learn
I'm working on a socket app in Ruby Shoes, and want to send a
I'm working on a project and I need to create an API. I am
I am working with sockets. Here are my codes (the description of problem is
I'm working on a client/server application in C#, and I need to get Asynchronous
Currently I am working with a embedded system that has the Linux OS. I

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.