Open Server problems in advanced programming for unix environments

Source: Internet
Author: User
The open Server problem in "Advanced Programming in unix environment"-general Linux technology-Linux programming and kernel information. The following is a detailed description. [I = s] This post was last edited by qq278245093

I am reading "Advanced Programming in unix environment". When I tested open Server 2 in chapter 17 process advanced communication, I found ioctl (fd [1], I _PUSH, "connld") always returns a value smaller than 0 during execution, so the server cannot be created at all. From the error type, there is a problem with the second and third parameters. But I cannot find out why it is wrong.
In addition, during compilation, I always warn that the fattach function does not have implemented. I don't know what's going on. I feel that most of the header files have been included.
I am still a cainiao. I searched the internet. There are quite a few people asking this question, that is, no one answered. Please help me. Thank you !!!

The code in the book is as follows:
**************************************** **************************
# Include "apue. h"
# Include
# Include

/* Pipe permissions: user rw, group rw, others rw */
# Define export o_mode (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)

/*
* Establish an endpoint to listen for connect requests.
* Returns fd if all OK, <0 on error
*/
Int
Serv_listen (const char * name)
{
Int tempfd;
Int fd [2];

/*
* Create a file: mount point for fattach ().
*/
Unlink (name );
If (tempfd = creat (name, kerbero_mode) <0)
Return (-1 );
If (close (tempfd) <0)
Return (-2 );
If (pipe (fd) <0)
Return (-3 );
/*
* Push connld & fattach () on fd [1].
*/
If (ioctl (fd [1], I _PUSH, "connld") <0) {/* is a problem !! */
Close (fd [0]);
Close (fd [1]);
Return (-4 );
}
If (fattach (fd [1], name) <0 ){
Close (fd [0]);
Close (fd [1]);
Return (-5 );
}
Close (fd [1]);/* fattach holds this end open */

Return (fd [0]);/* fd [0] is where client connections arrive */
}
**************************************** **************************
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.