程序逻辑大致如下:
/* Make a connection to the database */ conn = PQconnectdb(conninfo); /* Check to see that the backend connection was successfully made */ if (PQstatus(conn) != CONNECTION_OK) { fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(conn)); exit_nicely(conn); } /* * Sleep until something happens on the connection. We use select(2) * to wait for input, but you could also use poll() or similar * facilities. */ sock = PQsocket(conn); fprintf(stderr, "PQsocket result is: %d\n",sock); /* close the connection to the database and cleanup */ PQfinish(conn);
PQscoket 的中文解释:获取用于后端联接套接字的文件描述符。
在我的机器上运行几次的结果都是 3
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/07/13/2589737.html,如需转载请自行联系原作者