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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:56:00+00:00 2026-05-29T07:56:00+00:00

could be any difference in solving errors between this two functions?: To this question

  • 0

could be any difference in solving errors between this two functions?:
To this question brought me another question … is number of characters always same as number of bytes?
For more info: I use it in C on Linux for TCP socket comunication(sys/socket.h)
Thanks for your responses.

send()
write()

Return:
write():
On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately. If count is zero and the file descriptor refers to a regular file, 0 will be returned without causing any other effect. For a special file, the results are not portable.

send():
The calls return the number of characters sent, or -1 if an error occurred.

Question from stackoverflow which says that this methods should be same with using flag zero.
here

int client_sockfd;
char* msg;
int length = strlen(msg); 

//first option
if(send(client_sockfd, msg, length, 0) != length) return 1;
else return 0;
//second option 
if(write(client_sockfd, msg, length) != length) return 1;
else return 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-05-29T07:56:01+00:00Added an answer on May 29, 2026 at 7:56 am

    They will both return the same number of written bytes (== characters in this case. EXCEPT note this:

    If the message is too long to pass atomically through the underlying protocol, the
    error EMSGSIZE is returned, and the message is not transmitted.

    In other words, depending on the size of the data being written, write() may succeed where send() may fail.

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

Sidebar

Related Questions

could any one give me main difference between Netbeans Plateform and OSGI? Becoz i
What is difference between setFlags and addFlags for intent. Could any one explain it
This question pertains specifically to shell scripts, but could be about any programming language.
Is there any difference between these two declarations? int x[10]; vs. int* x =
a while ago i could comment any code in php with netbeans like this:
Once I created a form builder where user could select any number of fields
Is there any difference between @(posedge Clk); a<= 1'b1; and @(posedge Clk) a<= 1'b1;
Question: does operand order make any difference when evaluating equality or identity in JavaScript?
I have looked and I could not find this question before, and it surprises
Is there any difference between a Singleton class and a class with all static

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.