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

📄 qsocket.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.PPSee also bytesAvailable()..SH "void QSocket::bytesWritten ( int nbytes )\fC [signal]\fR"This signal is emitted when data has actually been written to the network. The \fInbytes\fR parameter specifies how many bytes were written..PPThe bytesToWrite() function is often used in the same context, and it says how many buffered bytes there are left to write..PPSee also writeBlock() and bytesToWrite()..SH "bool QSocket::canReadLine () const"Returns TRUE if it's possible to read an entire line of text from this socket at this time; otherwise returns FALSE..PPNote that if the peer closes the connection unexpectedly, this function returns FALSE. This means that loops such as this won't work:.PP.nf.br    while( !socket->canReadLine() ) // Wrong..br        ....br.fi.PPSee also readLine()..PPExamples:.)l network/clientserver/client/client.cpp, network/httpd/httpd.cpp, network/mail/smtp.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::close ()\fC [virtual]\fR"Closes the socket..PPThe read buffer is cleared..PPIf the output buffer is empty, the state is set to QSocket::Idle and the connection is terminated immediately. If the output buffer still contains data to be written, QSocket goes into the QSocket::Closing state and the rest of the data will be written. When all of the outgoing data have been written, the state is set to QSocket::Idle and the connection is terminated. At this point, the delayedCloseFinished() signal is emitted..PPSee also state() and bytesToWrite()..PPExamples:.)l network/clientserver/client/client.cpp, network/httpd/httpd.cpp and network/networkprotocol/nntp.cpp..PPReimplemented from QIODevice..SH "void QSocket::connectToHost ( const QString & host, Q_UINT16 port )\fC [virtual]\fR"Attempts to make a connection to \fIhost\fR on the specified \fIport\fR and return immediately..PPAny connection or pending connection is closed immediately, and QSocket goes into the HostLookup state. When the lookup succeeds, it emits hostFound(), starts a TCP connection and goes into the Connecting state. Finally, when the connection succeeds, it emits connected() and goes into the Connected state. If there is an error at any point, it emits error()..PP\fIhost\fR may be an IP address in string form, or it may be a DNS name. QSocket will do a normal DNS lookup if required. Note that \fIport\fR is in native byte order, unlike some other libraries..PPSee also state()..PPExamples:.)l network/clientserver/client/client.cpp, network/mail/smtp.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::connected ()\fC [signal]\fR"This signal is emitted after connectToHost() has been called and a connection has been successfully established..PPSee also connectToHost() and connectionClosed()..PPExamples:.)l network/clientserver/client/client.cpp, network/mail/smtp.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::connectionClosed ()\fC [signal]\fR"This signal is emitted when the other end has closed the connection. The read buffers may contain buffered input data which you can read after the connection was closed..PPSee also connectToHost() and close()..PPExamples:.)l network/clientserver/client/client.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::delayedCloseFinished ()\fC [signal]\fR"This signal is emitted when a delayed close is finished..PPIf you call close() and there is buffered output data to be written, QSocket goes into the QSocket::Closing state and returns immediately. It will then keep writing to the socket until all the data has been written. Then, the delayedCloseFinished() signal is emitted..PPSee also close()..PPExamples:.)l network/clientserver/client/client.cpp and network/httpd/httpd.cpp..SH "void QSocket::error ( int )\fC [signal]\fR"This signal is emitted after an error occurred. The parameter is the Error value..PPExamples:.)l network/clientserver/client/client.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::flush ()\fC [virtual]\fR"Implementation of the abstract virtual QIODevice::flush() function..PPReimplemented from QIODevice..SH "int QSocket::getch ()\fC [virtual]\fR"Reads a single byte/character from the internal read buffer. Returns the byte/character read, or -1 if there is nothing to be read..PPSee also bytesAvailable() and putch()..PPReimplemented from QIODevice..SH "void QSocket::hostFound ()\fC [signal]\fR"This signal is emitted after connectToHost() has been called and the host lookup has succeeded..PPSee also connected()..PPExample: network/networkprotocol/nntp.cpp..SH "bool QSocket::open ( int m )\fC [virtual]\fR"Opens the socket using the specified QIODevice file mode \fIm\fR. This function is called automatically when needed and you should not call it yourself..PPSee also close()..PPReimplemented from QIODevice..SH "QHostAddress QSocket::peerAddress () const"Returns the host address as resolved from the name specified to the connectToHost() function..SH "QString QSocket::peerName () const"Returns the host name as specified to the connectToHost() function. An empty string is returned if none has been set..PPExample: network/mail/smtp.cpp..SH "Q_UINT16 QSocket::peerPort () const"Returns the peer's host port number, normally as specified to the connectToHost() function. If none has been set, this function returns 0..PPNote that Qt always uses native byte order, i.e. 67 is 67 in Qt, there is no need to call htons()..SH "Q_UINT16 QSocket::port () const"Returns the host port number of this socket, in native byte order..SH "int QSocket::putch ( int ch )\fC [virtual]\fR"Writes the character \fIch\fR to the output buffer..PPReturns \fIch\fR, or -1 if some error occurred..PPSee also getch()..PPReimplemented from QIODevice..SH "Q_LONG QSocket::readBlock ( char * data, Q_ULONG 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..PPExample: network/networkprotocol/nntp.cpp..PPReimplemented from QIODevice..SH "QString QSocket::readLine ()\fC [virtual]\fR"Returns a line of text including a terminating newline character (\\n). Returns "" if canReadLine() returns FALSE..PPSee also canReadLine()..SH "void QSocket::readyRead ()\fC [signal]\fR"This signal is emitted when there is incoming data to be read..PPEvery time there is new incoming data this signal is emitted once. Bear in mind that new incoming data is only reported once; i.e. if you do not read all data, this signal is not emitted again unless new data arrives on the socket..PPSee also readBlock(), readLine() and bytesAvailable()..PPExamples:.)l network/clientserver/client/client.cpp, network/httpd/httpd.cpp, network/mail/smtp.cpp and network/networkprotocol/nntp.cpp..SH "void QSocket::setSocket ( int socket )\fC [virtual]\fR"Sets the socket to use \fIsocket\fR and the state() to Connected. The socket should already be connected..PPThis allows us to use the QSocket class as a wrapper for other socket types (e.g. Unix Domain Sockets under Unix)..PPExample: network/httpd/httpd.cpp..SH "void QSocket::setSocketDevice ( QSocketDevice * device )\fC [virtual]\fR"Sets the internal socket device to \fIdevice\fR. Passing a \fIdevice\fR of 0 will cause the internal socket device to be used. Any existing connection will be disconnected before using the new \fIdevice\fR..PPThe new device should not be connected before being associated with a QSocket; after setting the socket call connectToHost() to make the connection..PPThis function is useful if you need to subclass QSocketDevice and want to use the QSocket API, for example, to implement Unix domain sockets..SH "Offset QSocket::size () const\fC [virtual]\fR"Returns the number of incoming bytes that can be read right now (like bytesAvailable())..PPReimplemented from QIODevice..SH "void QSocket::sn_read ( bool force = FALSE )\fC [virtual protected slot]\fR"Internal slot for handling socket read notifications..PPThis function has can usually be only entered once (i.e. no recursive calls). If the argument \fIforce\fR is TRUE, the function is executed, but no readyRead() signals are emitted. This behaviour is useful for the waitForMore() function, so that it is possible to call waitForMore() in a slot connected to the readyRead() signal..SH "void QSocket::sn_write ()\fC [virtual protected slot]\fR"Internal slot for handling socket write notifications..SH "int QSocket::socket () const"Returns the socket number, or -1 if there is no socket at the moment..SH "QSocketDevice * QSocket::socketDevice ()"Returns a pointer to the internal socket device..PPThere is normally no need to manipulate the socket device directly since this class does the necessary setup for most applications..SH "State QSocket::state () const"Returns the current state of the socket connection..PPSee also QSocket::State..PPExamples:.)l network/clientserver/client/client.cpp and network/networkprotocol/nntp.cpp..SH "int QSocket::ungetch ( int ch )\fC [virtual]\fR"This implementation of the virtual function QIODevice::ungetch() prepends the character \fIch\fR to the read buffer so that the next read returns this character as the first character of the output..PPReimplemented from QIODevice..SH "Q_ULONG QSocket::waitForMore ( int msecs ) const"Wait up to \fImsecs\fR milliseconds for more data to be available..PPIf \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..PPSee also bytesAvailable()..SH "Q_LONG QSocket::writeBlock ( const char * data, Q_ULONG 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..PPExample: network/networkprotocol/nntp.cpp..PPReimplemented from QIODevice..SH "SEE ALSO".BR http://doc.trolltech.com/qsocket.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qsocket.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

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