Socket non-blocking setting error

Source: Internet
Author: User
Socket non-blocking setting error-Linux general technology-Linux programming and kernel information. The following is a detailed description. Some code
Pclient-> socket = socket (AF_INET, SOCK_STREAM, 0 );
Pclient-> _ addr. sin_family = AF_INET;
Pclient-> _ addr. sin_port = htons (pclient-> remote_port );
Pclient-> _ addr. sin_addr = * (struct in_addr *) he-> h_addr );
If (pclient-> socket =-1 ){
Return-1;
}
Flags = fcntl (pclient-> socket, F_GETFL, 0); client_recv (pclient, & lpbuf, 0) <= prp_enc_disable
Fcntl (pclient-> socket, F_SETFL, flags | O_NONBLOCK );

After the last two lines of comments are added, the program runs and sends a message to the server. messages can be received normally. an error is reported when the program stops running without commenting.
Error
* ** Glibc detected **./main: free () csi enable mclk
: Invalid pointer: 0xbe942558 ** prp_enc_disable
*
Aborted

How should we set it to non-blocking mode?
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.