23 #include "tdelibs_export.h"
30 #include <tqptrlist.h>
31 #include <tqiodevice.h>
33 #include "kbufferedio.h"
34 #include "ksockaddr.h"
40 class TQSocketNotifier;
49 #define IO_ListenError (IO_UnspecifiedError+1)
50 #define IO_AcceptError (IO_UnspecifiedError+2)
51 #define IO_LookupError (IO_UnspecifiedError+3)
53 class KExtendedSocketPrivate;
109 unixSocket = knownSocket | 0x02,
110 inetSocket = knownSocket | 0x04,
111 ipv4Socket = inetSocket | 0x100,
112 ipv6Socket = inetSocket | 0x200,
114 passiveSocket = 0x1000,
118 streamSocket = 0x8000,
119 datagramSocket = 0x10000,
122 inputBufferedSocket = 0x200000,
123 outputBufferedSocket = 0x400000,
124 bufferedSocket = 0x600000
139 lookupInProgress = 50,
197 KExtendedSocket(
const TQString& host,
const TQString& service,
int flags = 0);
221 int socketStatus()
const;
229 int systemError()
const;
236 int setSocketFlags(
int flags);
243 int socketFlags()
const;
258 bool setHost(
const TQString& host);
264 TQString host()
const;
270 bool setPort(
int port);
281 bool setPort(
const TQString& port);
287 TQString port()
const;
298 bool setAddress(
const TQString& host,
int port);
309 bool setAddress(
const TQString& host,
const TQString& serv);
316 bool setBindHost(
const TQString& host);
322 bool unsetBindHost();
328 TQString bindHost()
const;
335 bool setBindPort(
int port);
342 bool setBindPort(
const TQString& service);
348 bool unsetBindPort();
354 TQString bindPort()
const;
363 bool setBindAddress(
const TQString& host,
int port);
372 bool setBindAddress(
const TQString& host,
const TQString& service);
379 bool unsetBindAddress();
392 bool setTimeout(
int secs,
int usecs = 0);
398 timeval timeout()
const;
408 bool setBlockingMode(
bool enable);
425 bool setAddressReusable(
bool enable);
431 bool addressReusable();
451 bool setIPv6Only(
bool enable);
485 const ::TDESocketAddress *localAddress();
493 const ::TDESocketAddress *peerAddress();
499 inline int fd()
const
513 virtual int lookup();
533 virtual int startAsyncLookup();
538 virtual void cancelAsyncLookup();
547 virtual int listen(
int N = 5);
588 virtual int connect();
604 virtual int startAsyncConnect();
609 virtual void cancelAsyncConnect();
621 virtual bool open(
int mode = (
int)(IO_Raw | IO_ReadWrite));
630 virtual void close();
652 virtual void release();
673 virtual void flush();
679 virtual inline TQ_ULONG
size()
const
686 virtual inline TQ_ULONG
at()
const
694 virtual inline bool at(
int i)
695 { Q_UNUSED(i);
return true; }
734 virtual TQ_LONG readBlock(
char *data, TQ_ULONG maxlen);
759 virtual TQ_LONG writeBlock(
const char *data, TQ_ULONG len);
775 virtual int peekBlock(
char *data, uint maxlen);
783 virtual int unreadBlock(
const char *data, uint len);
818 virtual int putch(
int ch);
882 void socketActivityRead();
883 void socketActivityWrite();
884 void dnsResultsReady();
885 void startAsyncConnectSlot();
886 void connectionEvent();
890 TQSocketNotifier *readNotifier();
891 TQSocketNotifier *writeNotifier();
903 static int doLookup(
const TQString& host,
const TQString& serv, addrinfo& hint,
904 kde_addrinfo** result);
910 void setError(
int errorkind,
int error);
912 inline void cleanError()
913 { setError(IO_Ok, 0); }
918 void setSocketStatus(
int status);
934 static int resolve(sockaddr* sock, ksocklen_t len, TQString& host, TQString& port,
int flags = 0) TDE_DEPRECATED;
948 static
int resolve(::
TDESocketAddress* sock, TQString& host, TQString& port,
int flags = 0) TDE_DEPRECATED;
970 static TQPtrList<
KAddressInfo> lookup(const TQString& host, const TQString& port,
int flags = 0,
int *error = 0) TDE_DEPRECATED;
995 static TQString strError(
int code,
int syserr);
1006 static
bool setAddressReusable(
int fd,
bool enable) TDE_DEPRECATED;
1009 virtual
void virtual_hook(
int id,
void* data );
1011 KExtendedSocketPrivate *d;
1043 inline TDE_DEPRECATED
operator const ::TDESocketAddress*()
const
1049 inline TDE_DEPRECATED
operator const addrinfo&()
const
1056 inline TDE_DEPRECATED
operator const addrinfo*()
const
1064 inline TDE_DEPRECATED const ::TDESocketAddress*
address()
const
1071 int flags() const TDE_DEPRECATED;
1077 int family() const TDE_DEPRECATED;
1083 int socktype() const TDE_DEPRECATED;
1089 int protocol() const TDE_DEPRECATED;
1097 const
char* canonname() const TDE_DEPRECATED;
1103 inline
int length()
const
1104 {
if (addr)
return addr->
size();
return 0; }
TDE_DEPRECATEDconst ::TDESocketAddress * address() const
Returns the KAddressInfo's TDESocketAddress.
virtual void enableRead(bool enable)=0
Toggles the emission of the readyRead() signal whenever the device is ready for reading.
virtual void enableWrite(bool enable)=0
Toggles the emission of the readyWrite() signal whenever the device is ready for writing.
The extended socket class.
SockStatus
status of the class The status are sequential.
void connectionSuccess()
This signal is emitted whenever we connected asynchronously to a host.
void readyAccept()
This signal is emitted whenever this socket is ready to accept another socket.
void connectionFailed(int error)
This signal is emitted whenever our asynchronous connection attempt failed to all hosts listed.
virtual TQ_ULONG size() const
Returns length of this socket.
virtual int ungetch(int)
Unreads one character from the stream.
virtual bool atEnd() const
Returns true if we are at the end.
void lookupFinished(int count)
This signal is emitted whenever an asynchronous lookup process is done.
virtual bool at(int i)
Returns true if we are at position.
int fd() const
Returns the file descriptor.
virtual TQ_ULONG at() const
Returns relative position from start.
Flags
flags that can be passed down to the member functions
This abstract class implements basic functionality for buffered input/output.
virtual int waitForMore(int msec)=0
Waits for more data to be available and returns the amount of available data then.
virtual void closeNow()=0
Closes the stream now, discarding the contents of the write buffer.
virtual int unreadBlock(const char *data, uint len)
Unreads some data.
virtual bool setBufferSize(int rsize, int wsize=-2)
Sets the internal buffer size to value.
virtual int peekBlock(char *data, uint maxlen)=0
Reads into the user buffer at most maxlen bytes, but does not consume that data from the read buffer.
virtual int bytesAvailable() const
Returns the number of bytes available for reading in the read buffer.
Monitors a port for incoming TCP/IP connections.
virtual ksocklen_t size() const
Returns sockaddr structure size.
kndbgstream & flush(kndbgstream &s)
Does nothing.