23 #include "kdelibs_export.h" 34 #include <tqptrlist.h> 35 #include <tqiodevice.h> 37 #include "kbufferedio.h" 38 #include "ksockaddr.h" 44 class TQSocketNotifier;
53 #define IO_ListenError (IO_UnspecifiedError+1) 54 #define IO_AcceptError (IO_UnspecifiedError+2) 55 #define IO_LookupError (IO_UnspecifiedError+3) 57 class KExtendedSocketPrivate;
113 unixSocket = knownSocket | 0x02,
114 inetSocket = knownSocket | 0x04,
115 ipv4Socket = inetSocket | 0x100,
116 ipv6Socket = inetSocket | 0x200,
118 passiveSocket = 0x1000,
122 streamSocket = 0x8000,
123 datagramSocket = 0x10000,
126 inputBufferedSocket = 0x200000,
127 outputBufferedSocket = 0x400000,
128 bufferedSocket = 0x600000
143 lookupInProgress = 50,
201 KExtendedSocket(
const TQString& host,
const TQString& service,
int flags = 0);
230 int socketStatus()
const;
238 int systemError()
const;
245 int setSocketFlags(
int flags);
252 int socketFlags()
const;
267 bool setHost(
const TQString& host);
273 TQString host()
const;
279 bool setPort(
int port);
290 bool setPort(
const TQString& port);
296 TQString port()
const;
307 bool setAddress(
const TQString& host,
int port);
318 bool setAddress(
const TQString& host,
const TQString& serv);
325 bool setBindHost(
const TQString& host);
331 bool unsetBindHost();
337 TQString bindHost()
const;
344 bool setBindPort(
int port);
351 bool setBindPort(
const TQString& service);
357 bool unsetBindPort();
363 TQString bindPort()
const;
372 bool setBindAddress(
const TQString& host,
int port);
381 bool setBindAddress(
const TQString& host,
const TQString& service);
388 bool unsetBindAddress();
401 bool setTimeout(
int secs,
int usecs = 0);
407 timeval timeout()
const;
417 bool setBlockingMode(
bool enable);
434 bool setAddressReusable(
bool enable);
440 bool addressReusable();
460 bool setIPv6Only(
bool enable);
494 const ::KSocketAddress *localAddress();
502 const ::KSocketAddress *peerAddress();
508 inline int fd()
const 522 virtual int lookup();
542 virtual int startAsyncLookup();
547 virtual void cancelAsyncLookup();
556 virtual int listen(
int N = 5);
597 virtual int connect();
613 virtual int startAsyncConnect();
618 virtual void cancelAsyncConnect();
630 virtual bool open(TQ_OpenMode mode = (TQ_OpenMode)(IO_Raw | IO_ReadWrite));
639 virtual void close();
661 virtual void release();
682 virtual void flush();
689 virtual inline TQ_ULONG size()
const 692 virtual inline qint64 size()
const 700 virtual inline TQ_ULONG
at()
const 708 virtual inline bool at(
int i)
709 { Q_UNUSED(i);
return true; }
748 virtual TQT_TQIO_LONG tqreadBlock(
char *data, TQT_TQIO_ULONG maxlen);
773 virtual TQT_TQIO_LONG tqwriteBlock(
const char *data, TQT_TQIO_ULONG len);
789 virtual int peekBlock(
char *data, uint maxlen);
797 virtual int unreadBlock(
const char *data, uint len);
809 virtual int bytesAvailable()
const;
812 virtual qint64 bytesAvailable()
const;
837 virtual int putch(
int ch);
875 void lookupFinished(
int count);
880 void connectionSuccess();
887 void connectionFailed(
int error);
901 void socketActivityRead();
902 void socketActivityWrite();
903 void dnsResultsReady();
904 void startAsyncConnectSlot();
905 void connectionEvent();
909 TQSocketNotifier *readNotifier();
910 TQSocketNotifier *writeNotifier();
922 static int doLookup(
const TQString& host,
const TQString& serv, addrinfo& hint,
923 kde_addrinfo** result);
929 void setError(
int errorkind,
int error);
931 inline void cleanError()
932 { setError(IO_Ok, 0); }
937 void setSocketStatus(
int status);
953 static int resolve(sockaddr* sock, ksocklen_t len, TQString& host, TQString& port,
int flags = 0) KDE_DEPRECATED;
967 static int resolve(::
KSocketAddress* sock, TQString& host, TQString& port,
int flags = 0) KDE_DEPRECATED;
989 static TQPtrList<KAddressInfo> lookup(
const TQString& host,
const TQString& port,
int flags = 0,
int *error = 0) KDE_DEPRECATED;
997 static ::KSocketAddress *localAddress(
int fd) KDE_DEPRECATED;
1006 static ::KSocketAddress *peerAddress(
int fd) KDE_DEPRECATED;
1014 static TQString strError(
int code,
int syserr);
1025 static bool setAddressReusable(
int fd,
bool enable) KDE_DEPRECATED;
1028 virtual void virtual_hook(
int id,
void* data );
1030 KExtendedSocketPrivate *d;
1062 inline KDE_DEPRECATED
operator const ::KSocketAddress*()
const 1068 inline KDE_DEPRECATED
operator const addrinfo&()
const 1075 inline KDE_DEPRECATED
operator const addrinfo*()
const 1083 inline KDE_DEPRECATED const ::KSocketAddress*
address()
const 1090 int flags()
const KDE_DEPRECATED;
1096 int family()
const KDE_DEPRECATED;
1102 int socktype()
const KDE_DEPRECATED;
1108 int protocol()
const KDE_DEPRECATED;
1116 const char* canonname()
const KDE_DEPRECATED;
1123 {
if (addr)
return addr->
size();
return 0; }
1130 #endif // KEXTSOCK_H virtual int ungetch(int)
Unreads one character from the stream.
virtual TQ_ULONG at() const
Returns length of this socket.
kndbgstream & flush(kndbgstream &s)
Does nothing.
virtual void enableWrite(bool enable)=0
Toggles the emission of the readyWrite() signal whenever the device is ready for writing.
virtual bool atEnd() const
Returns true if we are at the end.
KDE_DEPRECATEDconst ::KSocketAddress * address() const
Returns the KAddressInfo's KSocketAddress.
virtual bool at(int i)
Returns true if we are at position.
virtual void closeNow()=0
Closes the stream now, discarding the contents of the write buffer.
This abstract class implements basic functionality for buffered input/output.
virtual int waitForMore(int msec)=0
Returns the number of bytes available for reading in the read buffer.
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...
int length() const
Returns the length of the KSocketAddress.
virtual ksocklen_t size() const
Returns sockaddr structure size.
int fd() const
Returns the file descriptor.
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.
The extended socket class.
SockStatus
status of the class The status are sequential.
Monitors a port for incoming TCP/IP connections.
Flags
flags that can be passed down to the member functions
virtual void enableRead(bool enable)=0
Toggles the emission of the readyRead() signal whenever the device is ready for reading.