Skip to content

PythonQt.QtNetwork.QTcpServer

QTcpServer

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

This class makes it possible to accept incoming TCP connections. You can specify the port or have QTcpServer pick one automatically. You can listen on a specific address or on all the machine's addresses.

Call listen() to have the server listen for incoming connections. The newConnection() signal is then emitted each time a client connects to the server.

Call nextPendingConnection() to accept the pending connection as a connected QTcpSocket. The function returns a pointer to a QTcpSocket in QAbstractSocket::ConnectedState that you can use for communicating with the client.

If an error occurs, serverError() returns the type of error, and errorString() can be called to get a human readable description of what happened.

When listening for connections, the address and port on which the server is listening are available as serverAddress() and serverPort().

Calling close() makes QTcpServer stop listening for incoming connections.

Although QTcpServer is mostly designed for use with an event loop, it's possible to use it without one. In that case, you must use waitForNewConnection(), which blocks until either a connection is available or a timeout expires.

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

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
acceptError function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtNetwork.QTcpServer.acceptError; argument details are not documented.
addPendingConnection function (self, socket: Any) -> None This function is called by [QTcpServer::incomingConnection](https://doc.qt.io/archives/qt-5.15/qtcpserver.html#incomingConnection)() to add the socket to the list of pending incoming connections.
blockSignals function (self, b: Any) -> bool X.blockSignals(b) -> bool (shared captured text)
childEvent function (self, event: Any) -> Any (shared captured text)
children function (self) -> tuple X.children() -> tuple (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
close function (self) -> None Closes the server.
connect function (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool X.connect(signal, receiver, slot, type) -> bool (shared captured text)
customEvent function (self, event: Any) -> Any (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
deleteLater function (self) -> Any (shared captured text)
destroyed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtNetwork.QTcpServer.destroyed; argument details are not documented.
disconnect function (self, signal: Any, receiver: Any, slot: Any) -> bool X.disconnect(signal, receiver, slot) -> bool (shared captured text)
dumpObjectInfo function (self) -> Any (shared captured text)
dumpObjectTree function (self) -> Any (shared captured text)
dynamicPropertyNames function (self) -> Any (shared captured text)
errorString function (self) -> str X.errorString() -> str
event function (self, event: Any) -> bool X.event(event) -> bool (shared captured text)
eventFilter function (self, watched: Any, event: Any) -> bool X.eventFilter(watched, event) -> bool (shared captured text)
findChild function (self, type: Any, name: Any) -> Any X.findChild(type, name) -> PythonQt.private.QObject (shared captured text)
findChildren function (self, type: Any, name: Any) -> tuple X.findChildren(type, name) -> tuple (shared captured text)
hasPendingConnections function (self) -> bool X.hasPendingConnections() -> bool
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
incomingConnection function (self, handle: int) -> None This virtual function is called by [QTcpServer](https://doc.qt.io/archives/qt-5.15/qtcpserver.html) when a new connection is available.
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
installEventFilter function (self, filterObj: Any) -> Any (shared captured text)
isListening function (self) -> bool X.isListening() -> bool
isSignalConnected function (self, signal: Any) -> bool X.isSignalConnected(signal) -> bool (shared captured text)
isWidgetType function (self) -> bool X.isWidgetType() -> bool (shared captured text)
isWindowType function (self) -> bool X.isWindowType() -> bool (shared captured text)
killTimer function (self, id: Any) -> Any (shared captured text)
listen function (self, address: Any, port: int) -> bool X.listen(address, port) -> bool
maxPendingConnections function (self) -> int X.maxPendingConnections() -> int
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text)
moveToThread function (self, thread: Any) -> Any (shared captured text)
newConnection function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtNetwork.QTcpServer.newConnection; argument details are not documented.
nextPendingConnection function (self) -> Any X.nextPendingConnection() -> PythonQt.QtNetwork.QTcpSocket
objectName attribute Any (shared captured text)
objectNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtNetwork.QTcpServer.objectNameChanged; argument details are not documented.
parent function (self) -> Any X.parent() -> PythonQt.private.QObject (shared captured text)
pauseAccepting function (self) -> None Pauses accepting new connections.
property function (self, name: Any) -> Any X.property(name) -> object (shared captured text)
proxy function (self) -> Any X.proxy() -> PythonQt.QtNetwork.QNetworkProxy
removeEventFilter function (self, obj: Any) -> Any (shared captured text)
resumeAccepting function (self) -> None Resumes accepting new connections.
sender function (self) -> Any X.sender() -> PythonQt.private.QObject (shared captured text)
senderSignalIndex function (self) -> int X.senderSignalIndex() -> int (shared captured text)
serverAddress function (self) -> Any X.serverAddress() -> PythonQt.QtNetwork.QHostAddress
serverError function (self) -> Any Returns an error code for the last error that occurred.
serverPort function (self) -> int X.serverPort() -> int
setMaxPendingConnections function (self, numConnections: int) -> None Sets the maximum number of pending accepted connections to numConnections.
setObjectName function (self, name: Any) -> Any (shared captured text)
setParent function (self, parent: Any) -> Any (shared captured text)
setProperty function (self, name: Any, value: Any) -> bool X.setProperty(name, value) -> bool (shared captured text)
setProxy function (self, networkProxy: Any) -> None Sets the explicit network proxy for this socket to networkProxy.
setSocketDescriptor function (self, socketDescriptor: int) -> bool X.setSocketDescriptor(socketDescriptor) -> bool
signalsBlocked function (self) -> bool X.signalsBlocked() -> bool (shared captured text)
socketDescriptor function (self) -> int X.socketDescriptor() -> int
startTimer function (self, interval: Any, timerType: Any) -> int X.startTimer(interval, timerType) -> int (shared captured text)
thread function (self) -> Any (shared captured text)
timerEvent function (self, event: Any) -> Any (shared captured text)
tr function (self, text: Any, ambig: Any, n: Any) -> str X.tr(text, ambig, n) -> str (shared captured text)
waitForNewConnection function (self, msec: int, timedOut: Any) -> bool X.waitForNewConnection(msec, timedOut) -> bool