⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qsocketdevice.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
📖 第 1 页 / 共 2 页
字号:
Reimplemented from QIODevice..SH "int QSocketDevice::at () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPThe read/write index is meaningless for a socket, therefore this function returns 0..PPReimplemented from QIODevice..SH "bool QSocketDevice::atEnd () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPThe read/write index is meaningless for a socket, therefore this always returns FALSE..PPReimplemented from QIODevice..SH "bool QSocketDevice::bind ( const QHostAddress & address, Q_UINT16 port ) \fC[virtual]\fR"Assigns a name to an unnamed socket. If the operation succeeds, bind() returns TRUE. Otherwise, it returns FALSE without changing what port() and address() return..PPbind() is used by servers for setting up incoming connections. Call bind() before listen()..SH "bool QSocketDevice::blocking () const"Returns TRUE if the socket is in blocking mode, or FALSE if it is in nonblocking mode or if the socket is invalid..PPNote that this function does not set error()..PP\fBWarning:\fR On Windows, this function always returns TRUE since the ioctlsocket() function is broken..PPSee also setBlocking() and isValid()..SH "int QSocketDevice::bytesAvailable () const"Returns the number of bytes available for reading, or -1 if an error occurred..PP\fBWarning:\fR On Microsoft Windows, we use the ioctlsocket() function to determine the number of bytes queued on the socket. According to Microsoft (KB Q125486), ioctlsocket() sometimes return an incorrect number. The only safe way to determine the amount of data on the socket is to read it using readBlock(). QSocket has workarounds to deal with this problem..SH "void QSocketDevice::close () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPCloses the socket and sets the socket identifier to -1 (invalid)..PP(This function ignores errors; if there are any then a file descriptor leakage might result. As far as we know, the only error that can arise is EBADF, and that would of course not cause leakage. There may be OS-specfic errors that we haven't come across, however.).PPSee also open()..PPReimplemented from QIODevice..SH "bool QSocketDevice::connect ( const QHostAddress & addr, Q_UINT16 port ) \fC[virtual]\fR"Connects to the IP address and port specified by \fIaddr.\fR Returns TRUE if it establishes a connection, and FALSE if not. error() explains why..PPNote that error() commonly returns NoError for non-blocking sockets; this just means that you can call connect() again in a little while and it'll probably succeed..SH "QSocketDevice::Error QSocketDevice::error() const"Returns the first error seen..SH "void QSocketDevice::flush () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPQSocketDevice does not buffer at all, so this is a no-op..PPReimplemented from QIODevice..SH "int QSocketDevice::getch () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PP\fBWarning:\fR getch() is implemented as a one-byte readBlock(), so it may be very slow if you call it more than a few times..PPSee also putch() and readBlock()..PPReimplemented from QIODevice..SH "bool QSocketDevice::isValid () const"Returns TRUE if this is a valid socket or FALSE if it is an invalid socket. This is actually a shortcut for socket() == -1..PPSee also socket()..SH "bool QSocketDevice::listen ( int backlog ) \fC[virtual]\fR"Specifies how many pending connections a server socket can have. Returns TRUE if the operation was successful, otherwise FALSE..PPThe listen() call only applies to sockets where type() is \fCStream,\fR not \fCDatagram\fR sockets. listen() must not be called before bind() or after accept(). It is common to use a \fIbacklog\fR value of 50 on most Unix systems..PPSee also bind() and accept()..SH "bool QSocketDevice::open ( int mode ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPOpens the socket using the specified QIODevice file \fImode.\fR This function is called from the QSocketDevice constructors and from the setSocket() function. You should not call it yourself..PPSee also close()..PPReimplemented from QIODevice..SH "QHostAddress QSocketDevice::peerAddress () const"Returns the address of the port this socket device is connected to. This may be 0.0.0.0 for a while, but is set to something sensible when there is a sensible value it can have..PPNote that for Datagram sockets, this is the source address of the last packet received..SH "Q_UINT16 QSocketDevice::peerPort () const"Returns the port number of the port this socket device is connected to. This may be 0 for a while, but is set to something sensible when there is a sensible value it can have..PPNote that for Datagram sockets, this is the source port of the last packet received..SH "Q_UINT16 QSocketDevice::port () const"Returns the port number of this socket device. This may be 0 for a while, but is set to something sensible when there is a sensible value it can have..SH "int QSocketDevice::putch ( int ch ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PP\fBWarning:\fR putch() is implemented as a one-byte writeBlock(), so it may be very slow if you call it more than a few times..PPSee also getch()..PPReimplemented from QIODevice..SH "int QSocketDevice::readBlock ( char * data, uint maxlen ) \fC[virtual]\fR"Reads max \fImaxlen\fR bytes from the socket into \fIdata\fR and returns the number of bytes read. Returns -1 if an error occurred..PPReimplemented from QIODevice..SH "int QSocketDevice::receiveBufferSize () const"Returns the size of the OS receive buffer..PPSee also setReceiveBufferSize()..SH "int QSocketDevice::sendBufferSize () const"Returns the size of the OS send buffer..PPSee also setSendBufferSize()..SH "void QSocketDevice::setAddressReusable ( bool enable ) \fC[virtual]\fR"Sets the address of this socket to be usable by other sockets too if \fIenable\fR is TRUE, and to be used exclusively by this socket if \fIenable\fR is FALSE..PPWhen a socket is reusable, other sockets can use the same port number (and IP address), which is in general good. Of course other sockets cannot use the same (address,port,peer-address,peer-port) 4-tuple as this socket, so there is no risk of confusing the two TCP connections..PPSee also addressReusable()..SH "void QSocketDevice::setBlocking ( bool enable ) \fC[virtual]\fR"Makes the socket blocking if \fIenable\fR is TRUE or nonblocking if \fIenable\fR is FALSE..PPSockets are blocking by default, but we recommend using nonblocking socket operations, especially for GUI programs that need to be responsive..PP\fBWarning:\fR On Windows, this function does nothing since the ioctlsocket() function is broken..PPWhenever you use a QSocketNotifier on Windows, the socket is immediately made nonblocking..PPSee also blocking() and isValid()..SH "void QSocketDevice::setError ( Error err ) \fC[protected]\fR"Allows subclasses to set the error state..SH "void QSocketDevice::setReceiveBufferSize ( uint size ) \fC[virtual]\fR"Sets the size of the OS receive buffer to \fIsize.\fR.PPThe OS receive buffer size effectively limits two things: How much data can be in transit at any one moment, and how much data can be received in one iteration of the main event loop..PPThe default is OS-dependent. A socket that receives large amounts of data is probably best off with a buffer size of 49152..SH "void QSocketDevice::setSendBufferSize ( uint size ) \fC[virtual]\fR"Sets the size of the OS send buffer to \fIsize.\fR.PPThe OS send buffer size effectively limits how much data can be in transit at any one moment..PPThe default is OS-dependent. A socket that sends large amounts of data is probably best off with a buffer size of 49152..SH "void QSocketDevice::setSocket ( int socket, Type type )"Sets an existing socket..PPThe \fItype\fR argument must match the actual socket type; \fCQSocketDevice::Stream\fR for a reliable, connection-oriented TCP socket, or \fCQSocketDevice::Datagram\fR for an unreliable, connectionless UDP socket..PPAny existing socket is closed..PPSee also isValid() and close()..SH "uint QSocketDevice::size () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPThe size is meaningless for a socket, therefore this function returns 0..PPReimplemented from QIODevice..SH "int QSocketDevice::socket () const"Returns the socket number, or -1 if it is an invalid socket..PPSee also isValid() and type()..SH "Type QSocketDevice::type () const"Returns the socket type; \fCQSocketDevice::Stream\fR for a reliable, connection-oriented TCP socket, or \fCQSocketDevice::Datagram\fR for an unreliable UDP socket..PPSee also socket()..SH "int QSocketDevice::ungetch ( int ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPThis implementation of ungetch returns -1 (error). A socket is a sequential device and does not allow any ungetch operation..PPReimplemented from QIODevice..SH "int QSocketDevice::waitForMore ( int msecs ) const"Wait up to \fImsecs\fR milliseconds for more data to be available. If \fImsecs\fR is -1 the call will block indefinitely..PPThis is a blocking call and should be avoided in event driven applications..PPReturns the number of bytes available for reading, or -1 if an error occurred..PPSee also bytesAvailable()..SH "int QSocketDevice::writeBlock ( const char * data, uint len ) \fC[virtual]\fR"Writes \fIlen\fR bytes to the socket from \fIdata\fR and returns the number of bytes written. Returns -1 if an error occurred..PPThis is used for \fCQSocketDevice::Stream\fR sockets..PPReimplemented from QIODevice..SH "int QSocketDevice::writeBlock ( const char * data, uint len, const QHostAddress & host, Q_UINT16 port ) \fC[virtual]\fR"Writes \fIlen\fR bytes to the socket from \fIdata\fR and returns the number of bytes written. Returns -1 if an error occurred..PPThis is used for \fCQSocketDevice::Datagram\fR sockets. You have to specify the\fIhost\fR and \fIport\fR of the destination of the data..SH "SEE ALSO".BR http://doc.trolltech.com/qsocketdevice.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -