Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QTcpServer class provides a TCP-based server. More...
Public Member Functions | |
QTcpServer (QObject parent=null) | |
| |
override void | CreateProxy () |
new void | Close () |
| |
new string | ErrorString () |
| |
virtual bool | HasPendingConnections () |
| |
new bool | IsListening () |
| |
new bool | Listen () |
| |
new bool | Listen (QHostAddress address, ushort port=0) |
| |
virtual QTcpSocket | NextPendingConnection () |
| |
new QHostAddress | ServerAddress () |
| |
new QAbstractSocket.SocketError | ServerError () |
| |
new ushort | ServerPort () |
| |
new bool | SetSocketDescriptor (int socketDescriptor) |
| |
new int | SocketDescriptor () |
| |
new bool | WaitForNewConnection (int msec=0) |
| |
new bool | WaitForNewConnection (int msec, ref bool timedOut) |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QObject | |
QObject (QObject parent=null) | |
| |
new bool | BlockSignals (bool b) |
| |
new System.Collections.Generic.List < QObject > | Children () |
| |
new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
new void | DeleteLater () |
| |
new bool | Disconnect (QObject receiver, string member=null) |
| |
new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
| |
new void | DumpObjectInfo () |
| |
new void | DumpObjectTree () |
| |
new System.Collections.Generic.List < QByteArray > | DynamicPropertyNames () |
| |
virtual bool | OnEvent (QEvent arg1) |
| |
virtual bool | EventFilter (QObject arg1, QEvent arg2) |
| |
new bool | Inherits (string classname) |
| |
new void | InstallEventFilter (QObject arg1) |
| |
new bool | IsWidgetType () |
| |
new void | KillTimer (int id) |
| |
new object | Property (string name) |
| |
new void | RemoveEventFilter (QObject arg1) |
| |
new bool | SetProperty (string name, object value) |
| |
new void | SetUserData (uint id, QObjectUserData data) |
new bool | SignalsBlocked () |
| |
new int | StartTimer (int interval) |
| |
new QObjectUserData | UserData (uint id) |
new void | Dispose () |
Public Member Functions inherited from QtCore.Qt | |
delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
delegate string | FuncStringQByteArray (QByteArray qByteArray) |
delegate QByteArray | FuncQByteArrayString (string @string) |
delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
delegate QObject | FuncQObject () |
Static Public Member Functions | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtCore.QObject | |
static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection) |
| |
static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
| |
static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
| |
static uint | RegisterUserData () |
static string | Tr (string s, string c=null) |
| |
static string | Tr (string s, string c, int n) |
| |
static string | TrUtf8 (string s, string c=null) |
| |
static string | TrUtf8 (string s, string c, int n) |
| |
Static Public Member Functions inherited from QtCore.Qt | |
static QDataStream | Write (QDataStream s, object p) |
static QDataStream | Write (QDataStream arg1, QSizeF arg2) |
static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Write (QDataStream arg1, QPoint arg2) |
static QDataStream | Write (QDataStream arg1, QLineF arg2) |
static QDataStream | Write (QDataStream arg1, QPointF arg2) |
static QDataStream | Write (QDataStream arg1, QChar arg2) |
static QDataStream | Write (QDataStream arg1, QByteArray arg2) |
static QDataStream | Write (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Write (QDataStream arg1, QRectF arg2) |
static QDataStream | Write (QDataStream arg1, QDateTime arg2) |
static QDataStream | Write (QDataStream arg1, QUrl arg2) |
static QDataStream | Write (QDataStream arg1, QTime arg2) |
static QDataStream | Write (QDataStream arg1, QLocale arg2) |
static QDataStream | Write (QDataStream arg1, QBitArray arg2) |
static QDataStream | Write (QDataStream arg1, QUuid arg2) |
static QDataStream | Write (QDataStream arg1, QLine arg2) |
static QDataStream | Write (QDataStream arg1, QDate arg2) |
static QDataStream | Write (QDataStream @out, QRegExp regExp) |
static QDataStream | Write (QDataStream arg1, QRect arg2) |
static QDataStream | Write (QDataStream arg1, QSize arg2) |
static QDataStream | Write (QDataStream s, QVariant.Type p) |
static QDataStream | Write (QDataStream arg1, string arg2) |
static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
static QDataStream | Read (QDataStream arg1, QChar arg2) |
static QDataStream | Read (QDataStream arg1, QLocale arg2) |
static QDataStream | Read (QDataStream arg1, QRect arg2) |
static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Read (QDataStream arg1, QDate arg2) |
static QDataStream | Read (QDataStream arg1, QUrl arg2) |
static QDataStream | Read (QDataStream arg1, QUuid arg2) |
static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Read (QDataStream arg1, QLineF arg2) |
static QDataStream | Read (QDataStream arg1, QRectF arg2) |
static QDataStream | Read (QDataStream arg1, QPointF arg2) |
static QDataStream | Read (QDataStream arg1, QLine arg2) |
static QDataStream | Read (QDataStream arg1, QBitArray arg2) |
static QDataStream | Read (QDataStream arg1, QSize arg2) |
static QDataStream | Read (QDataStream arg1, QDateTime arg2) |
static QDataStream | Read (QDataStream arg1, QTime arg2) |
static QDataStream | Read (QDataStream arg1, QPoint arg2) |
static QDataStream | Read (QDataStream @in, QRegExp regExp) |
static QDataStream | Read (QDataStream s, object p) |
static QDataStream | Read (QDataStream arg1, QByteArray arg2) |
static QDataStream | Read (QDataStream arg1, QSizeF arg2) |
static QDataStream | Read (QDataStream arg1, string arg2) |
static QDataStream | Read (QDataStream s, QVariant.Type p) |
static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
static double | qAcos (double v) |
static void | qAddPostRoutine (System.Action arg1) |
static string | qAppName () |
static double | qAsin (double v) |
static double | qAtan (double v) |
static double | qAtan2 (double x, double y) |
static void | qBadAlloc () |
static int | qCeil (double v) |
static ushort | qChecksum (string s, uint len) |
static QByteArray | qCompress (QByteArray data) |
static QByteArray | qCompress (QByteArray data, int compressionLevel=-1) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
static double | qCos (double v) |
static double | qExp (double v) |
static double | qFabs (double v) |
static double | qFastCos (double x) |
static double | qFastSin (double x) |
static string | qFlagLocation (string method) |
static int | qFloor (double v) |
static bool | qFuzzyCompare (double p1, double p2) |
static bool | qFuzzyCompare (float p1, float p2) |
static bool | qFuzzyIsNull (double d) |
static bool | qFuzzyIsNull (float f) |
static uint | qHash (QBitArray key) |
static uint | qHash (QChar key) |
static uint | qHash (QStringRef key) |
static uint | qHash (QUrl url) |
static uint | qHash (QPersistentModelIndex index) |
static uint | qHash (QByteArray key) |
static uint | qHash (QModelIndex index) |
static uint | qHash (uint key) |
static uint | qHash (sbyte key) |
static uint | qHash (byte key) |
static uint | qHash (short key) |
static uint | qHash (NativeLong key) |
static uint | qHash (ushort key) |
static uint | qHash (long key) |
static uint | qHash (ulong key) |
static uint | qHash (int key) |
static uint | qHash (string key) |
static uint | qHash (NativeULong key) |
static double | qInf () |
static Qt.ActionQtMsgTypeString | qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1) |
static int | qIntCast (float f) |
static int | qIntCast (double f) |
static bool | qIsFinite (double d) |
static bool | qIsFinite (float f) |
static bool | qIsInf (float f) |
static bool | qIsInf (double d) |
static bool | qIsNaN (float f) |
static bool | qIsNaN (double d) |
static bool | qIsNull (float f) |
static bool | qIsNull (double d) |
static double | qLn (double v) |
static double | qPow (double x, double y) |
static double | qQNaN () |
static void | qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
static void | qRemovePostRoutine (System.Action arg1) |
static int | qRound (double d) |
static long | qRound64 (double d) |
static double | qSNaN () |
static bool | qSharedBuild () |
static double | qSin (double v) |
static double | qSqrt (double v) |
static bool | qStringComparisonHelper (QStringRef s1, string s2) |
static double | qTan (double v) |
static QByteArray | qUncompress (QByteArray data) |
static QByteArray | qUncompress (Pointer< byte > data, int nbytes) |
static string | qVersion () |
static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
static QByteArray | Qgetenv (string varName) |
static bool | Qputenv (string varName, QByteArray value) |
static int | Qrand () |
static void | Qsrand (uint seed) |
static int | Qstrcmp (QByteArray str1, QByteArray str2) |
static int | Qstrcmp (QByteArray str1, string str2) |
static int | Qstrcmp (string str1, QByteArray str2) |
static int | Qstrcmp (string str1, string str2) |
static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
static Pointer< sbyte > | Qstrdup (string arg1) |
static int | Qstricmp (string arg1, string arg2) |
static uint | Qstrlen (string str) |
static int | Qstrncmp (string str1, string str2, uint len) |
static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
static int | Qstrnicmp (string arg1, string arg2, uint len) |
static uint | Qstrnlen (string str, uint maxlen) |
static string | QtTrId (string id, int n=-1) |
Protected Member Functions | |
QTcpServer (System.Type dummy) | |
new void | AddPendingConnection (QTcpSocket socket) |
| |
virtual void | IncomingConnection (int handle) |
| |
new void | OnNewConnection () |
| |
Protected Member Functions inherited from QtCore.QObject | |
QObject (System.Type dummy) | |
virtual void | OnChildEvent (QChildEvent arg1) |
| |
virtual void | ConnectNotify (string signal) |
| |
virtual void | OnCustomEvent (QEvent arg1) |
| |
new void | OnDestroyed (QObject arg1=null) |
| |
virtual void | DisconnectNotify (string signal) |
| |
new int | Receivers (string signal) |
| |
new QObject | Sender () |
| |
new int | SenderSignalIndex () |
| |
virtual void | OnTimerEvent (QTimerEvent arg1) |
| |
Properties | |
Slot | NewConnection |
| |
new int | MaxPendingConnections [get, set] |
| |
new QNetworkProxy | Proxy [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQTcpServerSignals | Emit [get] |
Properties inherited from QtCore.QObject | |
virtual EventHandler < QEventArgs< QChildEvent > > | ChildEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | CustomEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | Event |
| |
virtual EventHandler < QEventArgs< QTimerEvent > > | TimerEvent |
| |
Slot< QObject > | DestroyedQObject |
Slot | Destroyed |
| |
new QObject | Parent [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
new string | ObjectName [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
| |
static new QMetaObject | StaticQtMetaObject [get] |
new IQObjectSignals | Emit [get] |
The QTcpServer class provides a TCP-based server.
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.
Symbian Platform Security Requirements
On Symbian, processes which use this class must have the NetworkServices platform security capability. If the client process lacks this capability, it will lead to a panic.
Platform security capabilities are added via the TARGET.CAPABILITY qmake variable.
See also QTcpSocket, Fortune Server Example, Threaded Fortune Server Example, Loopback Example, and Torrent Example.
|
protected |
QtNetwork.QTcpServer.QTcpServer | ( | QObject | parent = null | ) |
Constructs a QTcpServer object.
parent is passed to the QObject constructor.
See also listen() and setSocketDescriptor().
|
protected |
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().
new void QtNetwork.QTcpServer.Close | ( | ) |
Closes the server. The server will no longer listen for incoming connections.
See also listen().
|
virtual |
Reimplemented from QtCore.QObject.
new void QtNetwork.QTcpServer.Dispose | ( | ) |
new string QtNetwork.QTcpServer.ErrorString | ( | ) |
Returns a human readable description of the last error that occurred.
See also serverError().
|
virtual |
Returns true if the server has a pending connection; otherwise returns false.
See also nextPendingConnection() and setMaxPendingConnections().
|
protectedvirtual |
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 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().
new bool QtNetwork.QTcpServer.IsListening | ( | ) |
Returns true if the server is currently listening for incoming connections; otherwise returns false.
See also listen().
new bool QtNetwork.QTcpServer.Listen | ( | ) |
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().
new bool QtNetwork.QTcpServer.Listen | ( | QHostAddress | address, |
ushort | 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().
|
virtual |
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.
0 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().
|
protected |
This signal is emitted every time a new connection is available.
See also hasPendingConnections() and nextPendingConnection().
new QHostAddress QtNetwork.QTcpServer.ServerAddress | ( | ) |
Returns the server's address if the server is listening for connections; otherwise returns QHostAddress::Null.
See also serverPort() and listen().
new QAbstractSocket.SocketError QtNetwork.QTcpServer.ServerError | ( | ) |
Returns an error code for the last error that occurred.
See also errorString().
new ushort QtNetwork.QTcpServer.ServerPort | ( | ) |
Returns the server's port if the server is listening for connections; otherwise returns 0.
See also serverAddress() and listen().
new bool QtNetwork.QTcpServer.SetSocketDescriptor | ( | int | 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().
new int QtNetwork.QTcpServer.SocketDescriptor | ( | ) |
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().
|
static |
|
static |
|
static |
|
static |
new bool QtNetwork.QTcpServer.WaitForNewConnection | ( | int | msec = 0 | ) |
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 0, *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().
new bool QtNetwork.QTcpServer.WaitForNewConnection | ( | int | msec, |
ref bool | timedOut | ||
) |
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 0, *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().
|
getprotected |
|
getset |
Returns the maximum number of pending accepted connections. The default is 30.
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.
|
addremove |
This signal is emitted every time a new connection is available.
See also hasPendingConnections() and nextPendingConnection().
|
getset |
Returns the network proxy for this socket. By default QNetworkProxy::DefaultProxy is used.
This function was introduced in Qt 4.1.
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.
|
staticget |