📄 qsocketdevice.3qt
字号:
.TH QSocketDevice 3qt "3 September 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQSocketDevice \- Platform-independent low-level socket API<h1 align=center>QSocketDevice Class Reference.br<small>[ network module ]</small></h1>.br.PP\fC#include <qsocketdevice.h>\fR.PPInherits QIODevice..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBType\fR { Stream, Datagram }".br.ti -1c.BI "\fBQSocketDevice\fR ( Type " "type" " = Stream ) ".br.ti -1c.BI "\fBQSocketDevice\fR ( int " "socket" ", Type type ) ".br.ti -1c.BI "virtual \fB~QSocketDevice\fR () ".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "Type \fBtype\fR () const".br.ti -1c.BI "int \fBsocket\fR () const".br.ti -1c.BI "virtual void \fBsetSocket\fR ( int " "socket" ", Type type ) ".br.ti -1c.BI "bool \fBblocking\fR () const".br.ti -1c.BI "virtual void \fBsetBlocking\fR ( bool ) ".br.ti -1c.BI "bool \fBaddressReusable\fR () const".br.ti -1c.BI "virtual void \fBsetAddressReusable\fR ( bool ) ".br.ti -1c.BI "int \fBreceiveBufferSize\fR () const".br.ti -1c.BI "virtual void \fBsetReceiveBufferSize\fR ( uint ) ".br.ti -1c.BI "int \fBsendBufferSize\fR () const".br.ti -1c.BI "virtual void \fBsetSendBufferSize\fR ( uint ) ".br.ti -1c.BI "virtual bool \fBconnect\fR ( const QHostAddress &, Q_UINT16 ) ".br.ti -1c.BI "virtual bool \fBbind\fR ( const QHostAddress &, Q_UINT16 ) ".br.ti -1c.BI "virtual bool \fBlisten\fR ( int backlog ) ".br.ti -1c.BI "virtual int \fBaccept\fR () ".br.ti -1c.BI "int \fBbytesAvailable\fR () const".br.ti -1c.BI "int \fBwaitForMore\fR ( int msecs ) 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 \fBwriteBlock\fR ( const char * " "data" ", uint " "len" ", const QHostAddress & " "host" ", Q_UINT16 port ) ".br.ti -1c.BI "Q_UINT16 \fBport\fR () const".br.ti -1c.BI "Q_UINT16 \fBpeerPort\fR () const".br.ti -1c.BI "QHostAddress \fBaddress\fR () const".br.ti -1c.BI "QHostAddress \fBpeerAddress\fR () const".br.ti -1c.BI "enum \fBError\fR { NoError, AlreadyBound, Inaccessible, NoResources, Bug, Impossible, NoFiles, ConnectionRefused, NetworkFailure, UnknownError }".br.ti -1c.BI "Error \fBerror\fR () const".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "void \fBsetError\fR ( Error err ) ".br.in -1c.SH DESCRIPTIONThe QSocketDevice class provides a platform-independent low-level socket API..PPThis class is not really meant for use outside Qt. It can be used to achieve some things that QSocket does not provide, but it's not particularly easy to understand or use..PPThe basic purpose of the class is to provide a QIODevice that works on sockets, wrapped in a platform-independent API..PPSee also QSocket, QSocketNotifier and QHostAddress..SS "Member Type Documentation".SH "QSocketDevice::Error"This enum type describes the error states of QSocketDevice. At present these errors are defined:.TP\fCNoError\fR - all is fine..TP\fCAlreadyBound\fR - bind() said so..TP\fCInaccessible\fR - the operating system or firewall prohibits something..TP\fCNoResources\fR - the operating system ran out of something..TP\fCBug\fR - there seems to be a bug in QSocketDevice..TP\fCImpossible\fR - the impossible happened, usually because you confused QSocketDevice horribly. Simple example:.IP.nf.br ::close( sd->socket() );.br sd->writeBlock( someData, 42 );.fi.IPThe libc ::close() closes the socket, but QSocketDevice is not aware of that. So when you call writeBlock(), the impossible happens..TP\fCNoFiles\fR - the operating system will not let QSocketDevice open another file..TP\fCConnectionRefused\fR - a connection attempt was rejected by the peer..TP\fCNetworkFailure\fR - there is a network failure between this host and... and whatever..TP\fCUnknownError\fR - the operating system reacted in a way that the Qt developers did not foresee..SH "QSocketDevice::Type"This enum type describes the type of the socket:.TP\fCStream\fR - a stream socket.TP\fCDatagram\fR - a datagram socket.SH MEMBER FUNCTION DOCUMENTATION.SH "QSocketDevice::QSocketDevice ( Type type = Stream )"Creates a QSocketDevice object for a stream or datagram socket..PPThe \fItype\fR argument must be either \fCQSocketDevice::Stream\fR for a reliable, connection-oriented TCP socket, or \fCQSocketDevice::Datagram\fR for an unreliable UDP socket..PPSee also blocking()..SH "QSocketDevice::QSocketDevice ( int socket, Type type )"Creates a QSocketDevice object for 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..SH "QSocketDevice::~QSocketDevice () \fC[virtual]\fR"Destroys the socket device and closes the socket if it is open..SH "int QSocketDevice::accept () \fC[virtual]\fR"Extracts the first connection from the queue of pending connections for this socket and returns a new socket identifier. Returns -1 if the operation failed..PPSee also bind() and listen()..SH "QHostAddress QSocketDevice::address () const"Returns the address of this socket device. 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..SH "bool QSocketDevice::addressReusable () const"Returns TRUE if the address of this socket can be used by other sockets at the same time, and FALSE if this socket claims exclusive ownership..PPSee also setAddressReusable()..SH "bool QSocketDevice::at ( int ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPThe read/write index is meaningless for a socket, therefore this function does nothing and returns TRUE..PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -