29 #include "ksocketbase.h" 30 #include "ksocketdevice.h" 34 class KNetwork::KSocketBasePrivate
51 : d(new KSocketBasePrivate)
53 d->socketOptions = Blocking;
67 d->socketOptions = opts;
73 return d->socketOptions;
122 TQMutexLocker locker(
mutex());
138 TQMutexLocker locker(
mutex());
145 d->capabilities |= add;
146 d->capabilities &= ~remove;
147 return d->capabilities;
152 return d->device != 0L;
157 d->socketError =
error;
172 reason = i18n(
"Socket error code NoError",
"no error");
176 reason = i18n(
"Socket error code LookupFailure",
177 "name lookup has failed");
181 reason = i18n(
"Socket error code AddressInUse",
182 "address already in use");
186 reason = i18n(
"Socket error code AlreadyBound",
187 "socket is already bound");
191 reason = i18n(
"Socket error code AlreadyCreated",
192 "socket is already created");
196 reason = i18n(
"Socket error code NotBound",
197 "socket is not bound");
201 reason = i18n(
"Socket error code NotCreated",
202 "socket has not been created");
206 reason = i18n(
"Socket error code WouldBlock",
207 "operation would block");
210 case ConnectionRefused:
211 reason = i18n(
"Socket error code ConnectionRefused",
212 "connection actively refused");
215 case ConnectionTimedOut:
216 reason = i18n(
"Socket error code ConnectionTimedOut",
217 "connection timed out");
221 reason = i18n(
"Socket error code InProgress",
222 "operation is already in progress");
226 reason = i18n(
"Socket error code NetFailure",
227 "network failure occurred");
231 reason = i18n(
"Socket error code NotSupported",
232 "operation is not supported");
236 reason = i18n(
"Socket error code Timeout",
237 "timed operation timed out");
241 reason = i18n(
"Socket error code UnknownError",
242 "an unknown/unexpected error has happened");
245 case RemotelyDisconnected:
246 reason = i18n(
"Socket error code RemotelyDisconnected",
247 "remote host closed connection");
251 reason = TQString::null;
266 case RemotelyDisconnected:
273 void KSocketBase::unsetSocketDevice()
294 if (tqreadBlock((
char*)&c, 1) != 1)
302 unsigned char c = (
unsigned char)ch;
303 if (tqwriteBlock((
char*)&c, 1) != 1)
bool blocking() const
Retrieves this socket's blocking mode.
static bool isFatalError(int code)
Returns true if the given error code is a fatal one, false otherwise.
KSocketDevice * socketDevice() const
Retrieves the socket implementation used on this socket.
bool addressReuseable() const
Retrieves this socket's address reuseability flag.
virtual bool setAddressReuseable(bool enable)
Sets this socket's address reuseable flag.
virtual int getch()
Reads one character from the socket.
bool broadcast() const
Retrieves this socket's Broadcast flag.
void resetError()
Resets the socket error code and the I/O Device's status.
virtual int putch(int ch)
Writes one character to the socket.
KActiveSocketBase()
Constructor.
TQMutex * mutex() const
Returns the internal mutex for this class.
SocketError error() const
Retrieves the socket error code.
TQString errorString() const
Returns the error string corresponding to this error condition.
virtual ~KSocketBase()
Destructor.
virtual ~KPassiveSocketBase()
Destructor.
int setRequestedCapabilities(int add, int remove=0)
Sets the internally requested capabilities for a socket device.
bool isIPv6Only() const
Retrieves this socket's IPv6 Only flag.
KSocketBase()
Default constructor.
A namespace to store all networking-related (socket) classes.
virtual bool setBroadcast(bool enable)
Sets this socket Broadcast flag.
virtual bool setIPv6Only(bool enable)
Sets this socket's IPv6 Only flag.
SocketError
Possible socket error codes.
void setError(SocketError error)
Sets the socket's error code.
void setError(int status, SocketError error)
Sets the socket's error code and the I/O Device's status.
virtual bool setSocketOptions(int opts)
Set the given socket options.
virtual ~KActiveSocketBase()
Destructor.
virtual void setSocketDevice(KSocketDevice *device)
Sets the socket implementation to be used on this socket.
KPassiveSocketBase()
Constructor.
bool hasDevice() const
Returns true if the socket device has been initialised in this object, either by calling socketDevice...
virtual bool setBlocking(bool enable)
Sets this socket's blocking mode.
Low-level socket functionality.
virtual int socketOptions() const
Retrieves the socket options that have been set.
Basic socket functionality.
static KSocketDevice * createDefault(KSocketBase *parent)
Creates a new default KSocketDevice object given the parent object.