Skip to content

PythonQt.QtNetwork.QTcpServer · declarations 001

Back to PythonQt.QtNetwork.QTcpServer

acceptError

acceptError(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtNetwork.QTcpServer.acceptError; argument details are not documented.

Supplemental documentation: Qt 5 reference:

[signal] void QTcpServer::acceptError(QAbstractSocket::SocketError socketError)

This signal is emitted when accepting a new connection results in an error. The socketError parameter describes the type of error that occurred.

This function was introduced in Qt 5.0.

See also pauseAccepting() and resumeAccepting().

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#acceptError

addPendingConnection

addPendingConnection(socket: Any) -> None

X.addPendingConnection(socket)

Supplemental documentation: Qt 5 reference:

[protected] void QTcpServer::addPendingConnection(QTcpSocket *socket)

This function is called by QTcpServer::incomingConnection() to add the socket to the list of pending incoming connections.

Note: Don't forget to call this member from reimplemented incomingConnection() if you do not want to break the Pending Connections mechanism.

This function was introduced in Qt 4.7.

See also incomingConnection().

Upstream PySide2 reference signatures (binding differences may apply):

addPendingConnection(self, socket: PySide2.QtNetwork.QTcpSocket) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#addPendingConnection

close

close() -> None

X.close()

Supplemental documentation: Qt 5 reference:

void QTcpServer::close()

Closes the server. The server will no longer listen for incoming connections.

See also listen().

Upstream PySide2 reference signatures (binding differences may apply):

close(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#close

destroyed

destroyed(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtNetwork.QTcpServer.destroyed; argument details are not documented.

errorString

errorString() -> str

X.errorString() -> str

Supplemental documentation: Qt 5 reference:

QString QTcpServer::errorString() const

Returns a human readable description of the last error that occurred.

See also serverError().

Upstream PySide2 reference signatures (binding differences may apply):

errorString(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#errorString

hasPendingConnections

hasPendingConnections() -> bool

X.hasPendingConnections() -> bool

Supplemental documentation: Qt 5 reference:

[virtual] bool QTcpServer::hasPendingConnections() const

Returns true if the server has a pending connection; otherwise returns false.

See also nextPendingConnection() and setMaxPendingConnections().

Upstream PySide2 reference signatures (binding differences may apply):

hasPendingConnections(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#hasPendingConnections

incomingConnection

incomingConnection(handle: int) -> None

X.incomingConnection(handle)

Supplemental documentation: Qt 5 reference:

[virtual protected] void QTcpServer::incomingConnection(qintptr socketDescriptor)

This virtual function is called by QTcpServer when a new connection is available. The socketDescriptor argument is the native socket descriptor for the accepted connection.

The base implementation creates a QTcpSocket, sets the socket descriptor and then stores the QTcpSocket in an internal list of pending connections. Finally newConnection() is emitted.

Reimplement this function to alter the server's behavior when a connection is available.

If this server is using QNetworkProxy then the socketDescriptor may not be usable with native socket functions, and should only be used with QTcpSocket::setSocketDescriptor().

Note: If another socket is created in the reimplementation of this method, it needs to be added to the Pending Connections mechanism by calling addPendingConnection().

Note: If you want to handle an incoming connection as a new QTcpSocket object in another thread you have to pass the socketDescriptor to the other thread and create the QTcpSocket object there and use its setSocketDescriptor() method.

See also newConnection(), nextPendingConnection(), and addPendingConnection().

Upstream PySide2 reference signatures (binding differences may apply):

incomingConnection(self, handle: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#incomingConnection

isListening

isListening() -> bool

X.isListening() -> bool

Supplemental documentation: Qt 5 reference:

bool QTcpServer::isListening() const

Returns true if the server is currently listening for incoming connections; otherwise returns false.

See also listen().

Upstream PySide2 reference signatures (binding differences may apply):

isListening(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#isListening

listen

listen(address: Any, port: int) -> bool

X.listen(address, port) -> bool

Supplemental documentation: Qt 5 reference:

bool QTcpServer::listen(const QHostAddress \&address \= QHostAddress::Any, quint16 port \= 0)

Tells the server to listen for incoming connections on address address and port port. If port is 0, a port is chosen automatically. If address is QHostAddress::Any, the server will listen on all network interfaces.

Returns true on success; otherwise returns false.

See also isListening().

Upstream PySide2 reference signatures (binding differences may apply):

listen(self, address: PySide2.QtNetwork.QHostAddress=..., port: int=...) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#listen

maxPendingConnections

maxPendingConnections() -> int

X.maxPendingConnections() -> int

Supplemental documentation: Qt 5 reference:

int QTcpServer::maxPendingConnections() const

Returns the maximum number of pending accepted connections. The default is 30.

See also setMaxPendingConnections() and hasPendingConnections().

Upstream PySide2 reference signatures (binding differences may apply):

maxPendingConnections(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#maxPendingConnections

newConnection

newConnection(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtNetwork.QTcpServer.newConnection; argument details are not documented.

Supplemental documentation: Qt 5 reference:

[signal] void QTcpServer::newConnection()

This signal is emitted every time a new connection is available.

See also hasPendingConnections() and nextPendingConnection().

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#newConnection

nextPendingConnection

nextPendingConnection() -> Any

X.nextPendingConnection() -> PythonQt.QtNetwork.QTcpSocket

Supplemental documentation: Qt 5 reference:

[virtual] QTcpSocket *QTcpServer::nextPendingConnection()

Returns the next pending connection as a connected QTcpSocket object.

The socket is created as a child of the server, which means that it is automatically deleted when the QTcpServer object is destroyed. It is still a good idea to delete the object explicitly when you are done with it, to avoid wasting memory.

nullptr is returned if this function is called when there are no pending connections.

Note: The returned QTcpSocket object cannot be used from another thread. If you want to use an incoming connection from another thread, you need to override incomingConnection().

See also hasPendingConnections().

Upstream PySide2 reference signatures (binding differences may apply):

nextPendingConnection(self) -> PySide2.QtNetwork.QTcpSocket

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#nextPendingConnection

objectNameChanged

objectNameChanged(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtNetwork.QTcpServer.objectNameChanged; argument details are not documented.

pauseAccepting

pauseAccepting() -> None

X.pauseAccepting()

Supplemental documentation: Qt 5 reference:

void QTcpServer::pauseAccepting()

Pauses accepting new connections. Queued connections will remain in queue.

This function was introduced in Qt 5.0.

See also resumeAccepting().

Upstream PySide2 reference signatures (binding differences may apply):

pauseAccepting(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#pauseAccepting

proxy

proxy() -> Any

X.proxy() -> PythonQt.QtNetwork.QNetworkProxy

Supplemental documentation: Qt 5 reference:

QNetworkProxy QTcpServer::proxy() const

Returns the network proxy for this socket. By default QNetworkProxy::DefaultProxy is used.

This function was introduced in Qt 4.1.

See also setProxy() and QNetworkProxy.

Upstream PySide2 reference signatures (binding differences may apply):

proxy(self) -> PySide2.QtNetwork.QNetworkProxy

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#proxy

resumeAccepting

resumeAccepting() -> None

X.resumeAccepting()

Supplemental documentation: Qt 5 reference:

void QTcpServer::resumeAccepting()

Resumes accepting new connections.

This function was introduced in Qt 5.0.

See also pauseAccepting().

Upstream PySide2 reference signatures (binding differences may apply):

resumeAccepting(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#resumeAccepting

serverAddress

serverAddress() -> Any

X.serverAddress() -> PythonQt.QtNetwork.QHostAddress

Supplemental documentation: Qt 5 reference:

QHostAddress QTcpServer::serverAddress() const

Returns the server's address if the server is listening for connections; otherwise returns QHostAddress::Null.

See also serverPort() and listen().

Upstream PySide2 reference signatures (binding differences may apply):

serverAddress(self) -> PySide2.QtNetwork.QHostAddress

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#serverAddress

serverError

serverError() -> Any

X.serverError()

Supplemental documentation: Qt 5 reference:

QAbstractSocket::SocketError QTcpServer::serverError() const

Returns an error code for the last error that occurred.

See also errorString().

Upstream PySide2 reference signatures (binding differences may apply):

serverError(self) -> PySide2.QtNetwork.QAbstractSocket.SocketError

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#serverError

serverPort

serverPort() -> int

X.serverPort() -> int

Supplemental documentation: Qt 5 reference:

quint16 QTcpServer::serverPort() const

Returns the server's port if the server is listening for connections; otherwise returns 0.

See also serverAddress() and listen().

Upstream PySide2 reference signatures (binding differences may apply):

serverPort(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#serverPort

setMaxPendingConnections

setMaxPendingConnections(numConnections: int) -> None

X.setMaxPendingConnections(numConnections)

Supplemental documentation: Qt 5 reference:

void QTcpServer::setMaxPendingConnections(int numConnections)

Sets the maximum number of pending accepted connections to numConnections. QTcpServer will accept no more than numConnections incoming connections before nextPendingConnection() is called. By default, the limit is 30 pending connections.

Clients may still able to connect after the server has reached its maximum number of pending connections (i.e., QTcpSocket can still emit the connected() signal). QTcpServer will stop accepting the new connections, but the operating system may still keep them in queue.

See also maxPendingConnections() and hasPendingConnections().

Upstream PySide2 reference signatures (binding differences may apply):

setMaxPendingConnections(self, numConnections: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#setMaxPendingConnections

setProxy

setProxy(networkProxy: Any) -> None

X.setProxy(networkProxy)

Supplemental documentation: Qt 5 reference:

void QTcpServer::setProxy(const QNetworkProxy \&networkProxy)

Sets the explicit network proxy for this socket to networkProxy.

To disable the use of a proxy for this socket, use the QNetworkProxy::NoProxy proxy type:

server->setProxy(QNetworkProxy::NoProxy);

This function was introduced in Qt 4.1.

See also proxy() and QNetworkProxy.

Upstream PySide2 reference signatures (binding differences may apply):

setProxy(self, networkProxy: PySide2.QtNetwork.QNetworkProxy) -> None

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#setProxy

setSocketDescriptor

setSocketDescriptor(socketDescriptor: int) -> bool

X.setSocketDescriptor(socketDescriptor) -> bool

Supplemental documentation: Qt 5 reference:

bool QTcpServer::setSocketDescriptor(qintptr socketDescriptor)

Sets the socket descriptor this server should use when listening for incoming connections to socketDescriptor. Returns true if the socket is set successfully; otherwise returns false.

The socket is assumed to be in listening state.

See also socketDescriptor() and isListening().

Upstream PySide2 reference signatures (binding differences may apply):

setSocketDescriptor(self, socketDescriptor: int) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#setSocketDescriptor

socketDescriptor

socketDescriptor() -> int

X.socketDescriptor() -> int

Supplemental documentation: Qt 5 reference:

qintptr QTcpServer::socketDescriptor() const

Returns the native socket descriptor the server uses to listen for incoming instructions, or -1 if the server is not listening.

If the server is using QNetworkProxy, the returned descriptor may not be usable with native socket functions.

See also setSocketDescriptor() and isListening().

Upstream PySide2 reference signatures (binding differences may apply):

socketDescriptor(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#socketDescriptor

waitForNewConnection

waitForNewConnection(msec: int, timedOut: Any) -> bool

X.waitForNewConnection(msec, timedOut) -> bool

Supplemental documentation: Qt 5 reference:

bool QTcpServer::waitForNewConnection(int msec \= 0, bool *timedOut \= nullptr)

Waits for at most msec milliseconds or until an incoming connection is available. Returns true if a connection is available; otherwise returns false. If the operation timed out and timedOut is not nullptr, *timedOut will be set to true.

This is a blocking function call. Its use is disadvised in a single-threaded GUI application, since the whole application will stop responding until the function returns. waitForNewConnection() is mostly useful when there is no event loop available.

The non-blocking alternative is to connect to the newConnection() signal.

If msec is -1, this function will not time out.

See also hasPendingConnections() and nextPendingConnection().

Upstream PySide2 reference signatures (binding differences may apply):

waitForNewConnection(self, msec: int) -> typing.Tuple[bool, bool]

Source: https://doc.qt.io/archives/qt-5.15/qtcpserver.html#waitForNewConnection