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

📄 qsocket.3qt

📁 tmark1.11:用于生成QT/EMBEDDED应用工程的Markfile文件
💻 3QT
字号:
.TH QSocket 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQSocket \- Buffered socket connection.SH SYNOPSIS.br.PP\fC#include <qsocket.h>\fR.PPInherits QIODevice and QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQSocket\fR ( QObject * " "parent" "=0, const char * " "name" "=0 )".br.ti -1c.BI "\fBQSocket\fR ( int " "socket" ", QObject * " "parent" "=0, const char * " "name" "=0 )".br.ti -1c.BI "\fB~QSocket\fR ()".br.ti -1c.BI "enum \fBState\fR { Idle, HostLookup, Connecting, Connection, Closing }".br.ti -1c.BI "State \fBstate\fR () const".br.ti -1c.BI "enum \fBMode\fR { Binary, Ascii }".br.ti -1c.BI "Mode \fBmode\fR () const".br.ti -1c.BI "void \fBsetMode\fR ( Mode )".br.ti -1c.BI "bool \fBconnectToHost\fR ( const QString & " "host" ", int port )".br.ti -1c.BI "QString \fBhost\fR () const".br.ti -1c.BI "int \fBport\fR () const".br.ti -1c.BI "virtual bool \fBopen\fR ( int mode )".br.ti -1c.BI "virtual void \fBclose\fR ()".br.ti -1c.BI "virtual void \fBflush\fR ()".br.ti -1c.BI "virtual uint \fBsize\fR () const".br.ti -1c.BI "virtual int \fBat\fR () const".br.ti -1c.BI "virtual bool \fBat\fR ( int )".br.ti -1c.BI "virtual bool \fBatEnd\fR () const".br.ti -1c.BI "int \fBbytesAvailable\fR () const".br.ti -1c.BI "int \fBbytesToWrite\fR () const".br.ti -1c.BI "virtual int \fBreadBlock\fR ( char * " "data" ", uint maxlen )".br.ti -1c.BI "virtual int \fBwriteBlock\fR ( const char * " "data" ", uint len )".br.ti -1c.BI "virtual int \fBgetch\fR ()".br.ti -1c.BI "virtual int \fBputch\fR ( int )".br.ti -1c.BI "virtual int \fBungetch\fR ( int )".br.ti -1c.BI "bool \fBcanReadLine\fR () const".br.ti -1c.BI "QString \fBreadLine\fR ()".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBhostFound\fR ()".br.ti -1c.BI "void \fBconnected\fR ()".br.ti -1c.BI "void \fBclosed\fR ()".br.ti -1c.BI "void \fBdelayedCloseFinished\fR ()".br.ti -1c.BI "void \fBreadyRead\fR ()".br.ti -1c.BI "void \fBbytesWritten\fR ( int nbytes )".br.ti -1c.BI "void \fBerror\fR ()".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "QSocketDevice* \fBsocketDevice\fR ()".br.ti -1c.BI "virtual void \fBtimerEvent\fR ( QTimerEvent * )".br.in -1c.SS "Protected Slots".in +1c.ti -1c.BI "virtual void \fBsn_read\fR ()".br.ti -1c.BI "virtual void \fBsn_write\fR ()".br.in -1c.SH DESCRIPTIONThe QSocket class provides a buffered socket connection..PPThis class provides a buffered TCP connection over a socket. Both read and write operations are buffered..PPSee also: QSocketDevice, QSocketAddress and QSocketNotifier..SS "Member Type Documentation".SH "QSocket::Mode"This enum specifies the communication mode:.TP\fCQSocket::Binary\fR (default).TP\fCQSocket::Ascii\fR.SH "<a name="State">QSocket::State"This enum contains the connection states:.TP\fCQSocket::Idle\fR if there is no connection,.TP\fCQSocket::HostLookup\fR during a host lookup,.TP\fCQSocket::Connecting\fR during an attempt to connect to a host, and.TP\fCQSocket::Connection\fR when there is a connection..SH MEMBER FUNCTION DOCUMENTATION.SH "<a name="5c1071">QSocket::QSocket ( QObject * parent=0, const char * name=0 )"Creates a QSocket object in \fCQSocket::Idle\fR state..PPThis socket can be used to make a connection to a host using the connectToHost() function..SH "QSocket::QSocket ( int socket, QObject * parent=0, const char * name=0 )"Creates a QSocket object for an existing connection using \fIsocket.\fR.PPThe socket is set to nonblocking and the socket option \fCQSocketDevice::ReuseAddress\fR is enabled..SH "QSocket::~QSocket ()"Destroys the socket. Closes the connection if necessary..PPSee also: close()..SH "bool QSocket::at ( int index ) \fC[virtual]\fR"Moves the read index forward and returns TRUE if the operation was successful. Moving the index forward means skipping incoming data..PPReimplemented from QIODevice..SH "int QSocket::at () const \fC[virtual]\fR"Returns the current read index. Since QSocket is a sequential device, the current read index is always zero..PPReimplemented from QIODevice..SH "bool QSocket::atEnd () const \fC[virtual]\fR"Returns TRUE if there is no more data to read, otherwise FALSE..PPReimplemented from QIODevice..SH "int QSocket::bytesAvailable () const"Returns the number of incoming bytes that can be read, i.e. the size of the input buffer. Equivalent to size()..PPSee also: bytesToWrite();..SH "int QSocket::bytesToWrite () const"Returns the number of bytes that are waiting to be written, i.e. the size of the output buffer..PPSee also: bytesAvailable..SH "void QSocket::bytesWritten ( int nbytes ) \fC[signal]\fR"This signal is emitted when data actually has been written to the network. The \fInbytes\fR parameter says how many bytes were written..PPThe bytesToWrite() function is often used in the same context, and it tells how many buffered bytes there are left to write..PPSee also: writeBlock() and bytesToWrite()..SH "bool QSocket::canReadLine () const"Returns TRUE if the socket is in ascii mode and readLine() can be called to read a line of text. Otherwise FALSE is returned..PPSee also: setMode() and readLine()..SH "void QSocket::close () \fC[virtual]\fR"Closes the socket. The mode to \fCQSocket::Binary\fR and the 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 \fCQSocket::Closing\fR state and the rest of the data will be written. When all of the outgoing data have been written, the state is set to \fCQSocket::Idle\fR and the connection is terminated. At this point, the delayedCloseFinished() signal is emitted..PPSee also: state(), setMode() and bytesToWrite()..PPReimplemented from QIODevice..SH "void QSocket::closed () \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()..SH "bool QSocket::connectToHost ( const QString & host, int port )"Attempts to make a connection to \fIhost\fR on the specified \fIport.\fR.PPAny connection or pending connection is closed immediately when you call this function..PPWhen making a connection, QSocket goes into the \fCQSocket::HostLookup\fR state while looking up the host. When the host has been found, QSocket will try to connect to the host and it goes into the \fCQSocket::Connecting\fR state. Finally, when a connection has been made, the state becomes \fCQSocket::Connection.\fR.PPTODO### No real error handling so far. Blocking host lookup..PPSee also: state()..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 closed()..SH "void QSocket::delayedCloseFinished () \fC[signal]\fR"This signal is emitted when a delayed close is finished. If you call close() and there is buffered output data to be written, QSocket goes into the \fCQSocket::Closing\fR state and returns immediately. It will then keep writing to the socket until all the data has been written. Then, the delayCloseFinished() signal is emitted..PPSee also: close()..SH "void QSocket::flush () \fC[virtual]\fR"Implementation of the abstract virtual QIODevice::flush() function. This implementation is a no-op..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 "QString QSocket::host () const"Returns the host name as specified to the connectToHost() function. If none has been set, the returned host name is ""..SH "void QSocket::hostFound () \fC[signal]\fR"This signal is emitted after connectToHost() has been called and a host has been looked up..PPSee also: connected()..SH "QSocket::Mode QSocket::mode() const"Returns the current communication mode, either \fCQSocket::Binary\fR or \fCQSocket::Ascii.\fR.PPThe default mode is \fCQSocket::Binary.\fR.PPThe documentation of setMode() explains this mode setting..PPSee also: setMode()..SH "bool QSocket::open ( int m ) \fC[virtual]\fR"Opens the socket using the specified QIODevice file mode. This function is called automatically when needed and you should not call it yourself..PPSee also: close()..PPReimplemented from QIODevice..SH "int QSocket::port () const"Returns the host port as specified to the connectToHost() function. If none has been set, the returned port is 0..SH "int QSocket::putch ( int ch ) \fC[virtual]\fR"Writes the character \fIch\fR into the output buffer..PPReturns \fIch,\fR or -1 if some error occurred..PPSee also: getch()..PPReimplemented from QIODevice..SH "int QSocket::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 "QString QSocket::readLine ()"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..PPWhen new data comes into the socket device, this signal is emitted immediately. If QSocket has old incoming data that you have not read, the signal is emitted once every second until you read everything..PPSee also: readBlock(), readLine() and bytesAvailable()..SH "void QSocket::setMode ( Mode mode )"Sets the communication mode to either binary or ascii..PPQSocket::Binary is the default..PPThe mode only relates to incoming data. If binary mode is set, you read data using the readBlock() function. bytesAvailable() tells you how much buffered data that can be read..PPIf ascii mode set, QSocket will look for newline characters (\\n) in the incoming data. You can call the canReadLine() function to check if there is a line of text to be read. If canReadLine() returns TRUE, you can read a complete line of incoming text using the readLine() function. The readBlock() and bytesAvailable() functions work just like in binary mode..PPThe close() function sets the mode to \fCQSocket::Binary.\fR.PPSee also: mode(), readBlock(), bytesAvailable(), canReadLine(), readLine() and close()..SH "uint QSocket::size () const \fC[virtual]\fR"Returns the number of incoming bytes that can be read, same as bytesAvailable()..PPReimplemented from QIODevice..SH "void QSocket::sn_read () \fC[virtual protected slot]\fR"Internal slot for handling socket read notifications..SH "void QSocket::sn_write () \fC[virtual protected slot]\fR"Internal slot for handling socket write notifications..SH "QSocketDevice * QSocket::socketDevice () \fC[protected]\fR"Returns a pointer to the internal socket device. The returned pointer is null if there is no connection or pending connection..PPThere is normally no need to manipulate the socket device directly since this class does all the necessary setup for most client or server socket applications..SH "QSocket::State QSocket::state() const"Returns the current state of the socket connection..SH "void QSocket::timerEvent ( QTimerEvent * e ) \fC[virtual protected]\fR"Processes timer events for QSocket. Emits the readyRead() signal if there if there is buffered input available for reading..PPReimplemented from QObject..SH "int QSocket::ungetch ( int ) \fC[virtual]\fR"This implementation of the virtual function QIODevice::ungetch() always returns -1 (error) because a QSocket is a sequential device and does not allow any ungetch operation..PPReimplemented from QIODevice..SH "int QSocket::writeBlock ( const char * data, uint len ) \fC[virtual]\fR"Writes \fIlen\fR bytes from the socket from \fIdata\fR and returns the number of bytes written. Returns -1 if an error occurred..PPReimplemented from QIODevice..SH "SEE ALSO".BR http://www.troll.no/qt/qsocket.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS.  See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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