source: vendor/synergy/current/lib/net/XSocket.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 2.3 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef XSOCKET_H
16#define XSOCKET_H
17
18#include "XIO.h"
19#include "XBase.h"
20#include "CString.h"
21#include "BasicTypes.h"
22
23//! Generic socket exception
24XBASE_SUBCLASS(XSocket, XBase);
25
26//! Socket bad address exception
27/*!
28Thrown when attempting to create an invalid network address.
29*/
30class XSocketAddress : public XSocket {
31public:
32 //! Failure codes
33 enum EError {
34 kUnknown, //!< Unknown error
35 kNotFound, //!< The hostname is unknown
36 kNoAddress, //!< The hostname is valid but has no IP address
37 kUnsupported, //!< The hostname is valid but has no supported address
38 kBadPort //!< The port is invalid
39 };
40
41 XSocketAddress(EError, const CString& hostname, int port) throw();
42
43 //! @name accessors
44 //@{
45
46 //! Get the error code
47 EError getError() const throw();
48 //! Get the hostname
49 CString getHostname() const throw();
50 //! Get the port
51 int getPort() const throw();
52
53 //@}
54
55protected:
56 // XBase overrides
57 virtual CString getWhat() const throw();
58
59private:
60 EError m_error;
61 CString m_hostname;
62 int m_port;
63};
64
65//! I/O closing exception
66/*!
67Thrown if a stream cannot be closed.
68*/
69XBASE_SUBCLASS_FORMAT(XSocketIOClose, XIOClose);
70
71//! Socket cannot bind address exception
72/*!
73Thrown when a socket cannot be bound to an address.
74*/
75XBASE_SUBCLASS_FORMAT(XSocketBind, XSocket);
76
77//! Socket address in use exception
78/*!
79Thrown when a socket cannot be bound to an address because the address
80is already in use.
81*/
82XBASE_SUBCLASS(XSocketAddressInUse, XSocketBind);
83
84//! Cannot connect socket exception
85/*!
86Thrown when a socket cannot connect to a remote endpoint.
87*/
88XBASE_SUBCLASS_FORMAT(XSocketConnect, XSocket);
89
90//! Cannot create socket exception
91/*!
92Thrown when a socket cannot be created (by the operating system).
93*/
94XBASE_SUBCLASS_FORMAT(XSocketCreate, XSocket);
95
96#endif
Note: See TracBrowser for help on using the repository browser.