PQsocket 函数的简单验证

程序逻辑大致如下:

    /* 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

posted @ 2012-07-13 10:21  健哥的数据花园  阅读(449)  评论(0编辑  收藏  举报