QBlkSocket.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                          Network socket i/o device                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 *        Copyright (C) 2003-2006 by Niall Douglas.   All Rights Reserved.       *
00007 *       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
00008 *********************************************************************************
00009 * This code is free software; you can redistribute it and/or modify it under    *
00010 * the terms of the GNU Library General Public License v2.1 as published by the  *
00011 * Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
00012 * "upgrade" this code to the GPL without my prior written permission.           *
00013 * Please consult the file "License_Addendum2.txt" accompanying this file.       *
00014 *                                                                               *
00015 * This code is distributed in the hope that it will be useful,                  *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
00018 *********************************************************************************
00019 * $Id:                                                                          *
00020 ********************************************************************************/
00021 
00022 
00023 #ifndef QBLKSOCKET_H
00024 #define QBLKSOCKET_H
00025 #include "QIODeviceS.h"
00026 #include "QHostAddress.h"
00027 
00028 namespace FX {
00029 
00034 class FXString;
00035 
00143 struct QBlkSocketPrivate;
00144 class FXAPIR QBlkSocket : public QIODeviceS
00145 {
00146     QBlkSocketPrivate *p;
00147     QBlkSocket &operator=(const QBlkSocket &);
00148     FXDLLLOCAL void fillInAddrs(bool incPeer);
00149     FXDLLLOCAL void zeroAddrs();
00150     FXDLLLOCAL void setupSocket();
00151     QBlkSocket(const QBlkSocket &o, int h);
00152     virtual FXDLLLOCAL void *int_getOSHandle() const;
00153 public:
00155     enum Type
00156     {
00157         Stream=0,   
00158         Datagram    
00159     };
00161     QBlkSocket(Type type=Stream, FXushort port=0);
00163     QBlkSocket(const QHostAddress &addr, FXushort port, Type type=Stream);
00165     QBlkSocket(const FXString &addr, FXushort port, Type type=Stream);
00167 #ifndef HAVE_CPP0XRVALUEREFS
00168 #ifdef HAVE_CONSTTEMPORARIES
00169     QBlkSocket(const QBlkSocket &o);
00170 #else
00171     QBlkSocket(QBlkSocket &o);
00172 #endif
00173 #else
00174 private:
00175     QBlkSocket(const QBlkSocket &); // disable copy constructor
00176 public:
00177     QBlkSocket(QBlkSocket &&o);
00178 #endif
00179     ~QBlkSocket();
00180 
00182     Type type() const;
00184     void setType(Type type);
00186     const QHostAddress &address() const;
00188     FXushort port() const;
00190     QHostAddress peerAddress() const;
00192     FXushort peerPort() const;
00194     const QHostAddress &requestedAddress() const;
00196     FXushort requestedPort() const;
00198     void setRequestedAddressAndPort(const QHostAddress &reqAddr, FXushort port);
00200     bool isUnique() const;
00202     void setUnique(bool a);
00204     FXuval receiveBufferSize() const;
00206     void setReceiveBufferSize(FXuval newsize);
00208     FXuval sendBufferSize() const;
00210     void setSendBufferSize(FXuval newsize);
00214     FXuval maxDatagramSize() const;
00216     FXint maxPending() const;
00218     void setMaxPending(FXint newp);
00220     bool listen(int newp) { setMaxPending(newp); return true; }
00222     bool addressReusable() const;
00224     void setAddressReusable(bool newar);
00226     bool keepAlive() const;
00228     void setKeepAlive(bool newar);
00230     FXint lingerPeriod() const;
00232     void setLingerPeriod(FXint period);
00234     bool usingNagles() const;
00236     void setUsingNagles(bool newar);
00238     bool connected() const;
00239 
00243     bool create(FXuint mode=IO_ReadWrite);
00245     bool open(FXuint mode=IO_ReadWrite);
00247     void close();
00249     void flush();
00251     bool reset();
00252 
00254     FXfval size() const;
00258     FXDEPRECATEDEXT FXfval bytesAvailable() const { return size(); }
00260     virtual const FXACL &permissions() const;
00261 
00270     FXuval readBlock(char *data, FXuval maxlen);
00280     FXuval writeBlock(const char *data, FXuval maxlen);
00284     FXuval writeBlock(const char *data, FXuval maxlen, const QHostAddress &addr, FXushort port);
00286     int ungetch(int);
00293     QBlkSocket *waitForConnection(FXuint waitfor=FXINFINITE);
00294 
00295 public:
00297     FXDEPRECATEDEXT bool blocking() const { return true; }
00299     FXDEPRECATEDEXT void setBlocking(bool) { }
00301     FXDEPRECATEDEXT FXuval waitForMore(int msecs, bool *timeout=0);
00302 };
00303 
00304 } // namespace
00305 
00306 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:25 2009 for TnFOX by doxygen v1.4.7