The latest basic network socket programming-general Linux technology-Linux programming and kernel information is shown below. Open the door to the basics of network programming for new users, hoping to help new users!
Encapsulate the source code of the read and write functions provided by the system: (the file is saved as iolib. h)
# Include
# Include
# Include
Ssize_t my_read (int fd, void * buf, size_t length)
{
Ssize_t done = length;
While (done> 0)
{
Done = read (fd, buf, length );
If (done! = Length)
If (errno = EINTR)
Done = length;
Else
{
Perror ("fail to read! \ N ");
Return-1;
}
Else
Break;
}
Return done;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service