PQsocket 函数的简单验证

程序逻辑大致如下:

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);
PQsocket 函数的简单验证

PQscoket 的中文解释:获取用于后端联接套接字的文件描述符。

在我的机器上运行几次的结果都是 3









本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/07/13/2589737.html,如需转载请自行联系原作者


上一篇:linux安装fprot扫描病毒


下一篇:SAP CRM user参数CRM_UI_PROFILE是在哪行ABAP代码里读取的