<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # QTcpServer Class Reference ## [[QtNetwork](index.htm) module] 該QTcpServer既可類提供了一個基于TCP的服務器。[More...](#details) 繼承[QObject](qobject.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `addPendingConnection (self, QTcpSocket?socket)` * `close (self)` * `QString errorString (self)` * `bool hasPendingConnections (self)` * `incomingConnection (self, int?handle)` * `bool isListening (self)` * `bool listen (self, QHostAddress?address?=?QHostAddress.Any, int?port?=?0)` * `int maxPendingConnections (self)` * `QTcpSocket nextPendingConnection (self)` * `QNetworkProxy proxy (self)` * `QHostAddress serverAddress (self)` * `QAbstractSocket.SocketError serverError (self)` * `int serverPort (self)` * `setMaxPendingConnections (self, int?numConnections)` * `setProxy (self, QNetworkProxy?networkProxy)` * `bool setSocketDescriptor (self, int?socketDescriptor)` * `int socketDescriptor (self)` * `(bool, bool?timedOut) waitForNewConnection (self, int?msecs?=?0)` ### Qt Signals * `void newConnection ()` * * * ## Detailed Description 該QTcpServer既可類提供了一個基于TCP的服務器。 這個類使得它可以接受傳入的TCP連接。您可以指定端口或有QTcpServer既可選擇一個自動。你可以監聽一個特定的地址或所有機器的地址。 Call [listen](qtcpserver.html#listen)( )使服務器偵聽傳入的連接。該[newConnection](qtcpserver.html#newConnection)( )信號,然后每個客戶端連接到服務器時發出的。 Call [nextPendingConnection](qtcpserver.html#nextPendingConnection)( )接受掛起的連接作為一個連接[QTcpSocket](qtcpsocket.html)。該函數返回一個指針,指向一個[QTcpSocket](qtcpsocket.html)在[QAbstractSocket.ConnectedState](qabstractsocket.html#SocketState-enum)您可以使用與客戶端通信。 如果發生錯誤,[serverError](qtcpserver.html#serverError)()返回的錯誤的類型,并且[errorString](qtcpserver.html#errorString)( )可以被調用來獲取發生了什么可讀的描述。 當偵聽連接的地址和端口的服務器正在監聽可作為[serverAddress](qtcpserver.html#serverAddress)()和[serverPort](qtcpserver.html#serverPort)( ) 。 調用[close](qtcpserver.html#close)( )使得QTcpServer既可停止偵聽傳入的連接。 雖然QTcpServer既可主要是設計用于與一個事件循環使用,它可以使用它沒有之一。在這種情況下,您必須使用[waitForNewConnection](qtcpserver.html#waitForNewConnection)( ) ,這阻止,直到一個連接可用或者超時。 ### Symbian Platform Security Requirements 在Symbian ,它使用這個類的進程必須有`NetworkServices`平臺的安全能力。如果客戶端程序缺乏這種能力,它會導致恐慌。 平臺的安全功能是通過添加[TARGET.CAPABILITY](index.htm#target-capability)qmake的變量。 * * * ## Method Documentation ``` QTcpServer.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個[QTcpServer](qtcpserver.html)對象。 _parent_被傳遞到[QObject](qobject.html)構造函數。 **See also** [listen](qtcpserver.html#listen)()和[setSocketDescriptor](qtcpserver.html#setSocketDescriptor)( ) 。 ``` QTcpServer.addPendingConnection (self, QTcpSocket?socket) ``` 調用此函數由[QTcpServer.incomingConnection](qtcpserver.html#incomingConnection)( )來添加_socket_要掛起傳入連接的列表。 **Note:**不要忘了從重新實現調用這個成員[incomingConnection](qtcpserver.html#incomingConnection)()如果你不想打破掛起連接機制。 此功能被引入Qt的4.7 。 **See also** [incomingConnection](qtcpserver.html#incomingConnection)( ) 。 ``` QTcpServer.close (self) ``` 關閉服務器。該服務器將不再偵聽傳入的連接。 **See also** [listen](qtcpserver.html#listen)( ) 。 ``` QString QTcpServer.errorString (self) ``` 返回上次發生錯誤的可讀描述。 **See also** [serverError](qtcpserver.html#serverError)( ) 。 ``` bool QTcpServer.hasPendingConnections (self) ``` 返回True ,如果服務器有一個掛起的連接,否則返回False 。 **See also** [nextPendingConnection](qtcpserver.html#nextPendingConnection)()和[setMaxPendingConnections](qtcpserver.html#setMaxPendingConnections)( ) 。 ``` QTcpServer.incomingConnection (self, int?handle) ``` 這個虛函數被調用[QTcpServer](qtcpserver.html)當一個新的連接可用。該_socketDescriptor_參數是為接受的連接的本地套接字描述符。 該基地實現創建一個[QTcpSocket](qtcpsocket.html),設置套接字描述符,然后存儲[QTcpSocket](qtcpsocket.html)在掛起連接的內部清單。最后[newConnection](qtcpserver.html#newConnection)()被發射。 重新實現這個函數來改變服務器的行為,當一個連接可用。 如果該服務器使用[QNetworkProxy](qnetworkproxy.html)那么_socketDescriptor_可能與原生socket函數使用,并且只應使用[QTcpSocket.setSocketDescriptor](qabstractsocket.html#setSocketDescriptor)( ) 。 **Note:**如果你想處理的新傳入的連接[QTcpSocket](qtcpsocket.html)在另一個線程對象,你必須將socketDescriptor傳遞給其他線程,并創建[QTcpSocket](qtcpsocket.html)有對象并使用其[setSocketDescriptor](qtcpserver.html#setSocketDescriptor)()方法。 **See also** [newConnection](qtcpserver.html#newConnection)( )[nextPendingConnection](qtcpserver.html#nextPendingConnection)()和[addPendingConnection](qtcpserver.html#addPendingConnection)( ) 。 ``` bool QTcpServer.isListening (self) ``` 返回True如果服務器當前正在偵聽傳入連接,否則返回False 。 **See also** [listen](qtcpserver.html#listen)( ) 。 ``` bool QTcpServer.listen (self, QHostAddress?address?=?QHostAddress.Any, int?port?=?0) ``` 告訴服務器監聽的地址傳入的連接_address_和端口_port_。如果_port_為0 ,端口會自動選擇。如果_address_ is [QHostAddress.Any](qhostaddress.html#SpecialAddress-enum),服務器將監聽所有網絡接口。 成功時返回TRUE ,否則返回False 。 **See also** [isListening](qtcpserver.html#isListening)( ) 。 ``` int QTcpServer.maxPendingConnections (self) ``` 返回未決接受的連接的最大數目。默認值是30 。 **See also** [setMaxPendingConnections](qtcpserver.html#setMaxPendingConnections)()和[hasPendingConnections](qtcpserver.html#hasPendingConnections)( ) 。 ``` QTcpSocket QTcpServer.nextPendingConnection (self) ``` [](qtcpsocket.html) [返回的連接下一個待連接](qtcpsocket.html)[QTcpSocket](qtcpsocket.html)對象。 套接字被作為服務器的一個子創建的,這意味著它被自動刪除時[QTcpServer](qtcpserver.html)對象被銷毀。它仍然是一個好主意,明確地刪除的對象,當你用它做,以避免浪費內存。 如果這個函數被調用時,有沒有掛起的連接則返回0 。 **Note:**返回[QTcpSocket](qtcpsocket.html)對象不能被用于從另一個線程。如果你想使用從另一個線程傳入的連接,你需要重寫[incomingConnection](qtcpserver.html#incomingConnection)( ) 。 **See also** [hasPendingConnections](qtcpserver.html#hasPendingConnections)( ) 。 ``` QNetworkProxy QTcpServer.proxy (self) ``` [](qnetworkproxy.html) [返回此套接字的網絡代理。默認情況下,](qnetworkproxy.html)[QNetworkProxy.DefaultProxy](qnetworkproxy.html#ProxyType-enum)被使用。 這個函數是Qt 4.1中引入。 **See also** [setProxy](qtcpserver.html#setProxy)()和[QNetworkProxy](qnetworkproxy.html)。 ``` QHostAddress QTcpServer.serverAddress (self) ``` [](qhostaddress.html) [返回如果服務器正在監聽等待連接的服務器的地址,否則返回](qhostaddress.html)[QHostAddress.Null](qhostaddress.html#SpecialAddress-enum)。 **See also** [serverPort](qtcpserver.html#serverPort)()和[listen](qtcpserver.html#listen)( ) 。 ``` QAbstractSocket.SocketError QTcpServer.serverError (self) ``` [ 所發生的最后一個錯誤返回一個錯誤代碼。 ](qabstractsocket.html#SocketError-enum) [**See also**](qabstractsocket.html#SocketError-enum) [errorString](qtcpserver.html#errorString)( ) 。 ``` int QTcpServer.serverPort (self) ``` 返回如果服務器偵聽連接服務器的端口,否則返回0 。 **See also** [serverAddress](qtcpserver.html#serverAddress)()和[listen](qtcpserver.html#listen)( ) 。 ``` QTcpServer.setMaxPendingConnections (self, int?numConnections) ``` 設置掛起接受的最大連接數_numConnections_。[QTcpServer](qtcpserver.html)將接受不超過_numConnections_前傳入的連接[nextPendingConnection](qtcpserver.html#nextPendingConnection)()被調用。默認情況下,該限制是30未決的連接。 客戶可能仍然能夠服務器后連接已經達到了掛起連接的最大數目(即,[QTcpSocket](qtcpsocket.html)依然能發出連接( )信號) 。[QTcpServer](qtcpserver.html)將停止接受新的連接,但操作系統仍可能保持他們在隊列中。 **See also** [maxPendingConnections](qtcpserver.html#maxPendingConnections)()和[hasPendingConnections](qtcpserver.html#hasPendingConnections)( ) 。 ``` QTcpServer.setProxy (self, QNetworkProxy?networkProxy) ``` 設置此套接字明確網絡代理_networkProxy_。 要禁用使用代理的這個插座,使用[QNetworkProxy.NoProxy](qnetworkproxy.html#ProxyType-enum)代理類型: ``` server->setProxy([QNetworkProxy](qnetworkproxy.html).NoProxy); ``` 這個函數是Qt 4.1中引入。 **See also** [proxy](qtcpserver.html#proxy)()和[QNetworkProxy](qnetworkproxy.html)。 ``` bool QTcpServer.setSocketDescriptor (self, int?socketDescriptor) ``` 設置套接字描述符偵聽傳入的連接時,該服務器應該使用_socketDescriptor_。返回True如果套接字設置成功,否則返回False 。 該插座被假定為處于監聽狀態。 **See also** [socketDescriptor](qtcpserver.html#socketDescriptor)()和[isListening](qtcpserver.html#isListening)( ) 。 ``` int QTcpServer.socketDescriptor (self) ``` 返回服務器用來偵聽傳入的指令,或-1,如果服務器沒有監聽本地套接字描述符。 如果服務器使用[QNetworkProxy](qnetworkproxy.html),返回的描述符可能無法與原生socket函數使用。 **See also** [setSocketDescriptor](qtcpserver.html#setSocketDescriptor)()和[isListening](qtcpserver.html#isListening)( ) 。 ``` (bool, bool?timedOut) QTcpServer.waitForNewConnection (self, int?msecs?=?0) ``` 最多等待_msec_毫秒或直到傳入的連接是可用的。返回True如果連接可用,否則返回False 。如果操作超時,_timedOut_不為0, *_timedOut_將被設置為True。 這是一個阻塞函數調用。它的使用disadvised在一個單線程的GUI應用程序,因為整個應用程序將停止響應,直到函數返回。當沒有事件循環可用waitForNewConnection ( )是最有用。 非阻塞的替代方法是連接到[newConnection](qtcpserver.html#newConnection)()信號。 如果毫秒為-1 ,此功能將不會超時。 **See also** [hasPendingConnections](qtcpserver.html#hasPendingConnections)()和[nextPendingConnection](qtcpserver.html#nextPendingConnection)( ) 。 * * * ## Qt Signal Documentation ``` void newConnection () ``` 這是該信號的默認超載。 每當一個新的連接是可用的,這個信號被發射。 **See also** [hasPendingConnections](qtcpserver.html#hasPendingConnections)()和[nextPendingConnection](qtcpserver.html#nextPendingConnection)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看