• Main Page
  • Classes
  • Files
  • File List

XSocket.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include "XSocket.h"
00020 #include "CStringUtil.h"
00021 
00022 //
00023 // XSocketAddress
00024 //
00025 
00026 XSocketAddress::XSocketAddress(EError error,
00027                 const CString& hostname, int port) throw() :
00028     m_error(error),
00029     m_hostname(hostname),
00030     m_port(port)
00031 {
00032     // do nothing
00033 }
00034 
00035 XSocketAddress::EError
00036 XSocketAddress::getError() const throw()
00037 {
00038     return m_error;
00039 }
00040 
00041 CString
00042 XSocketAddress::getHostname() const throw()
00043 {
00044     return m_hostname;
00045 }
00046 
00047 int
00048 XSocketAddress::getPort() const throw()
00049 {
00050     return m_port;
00051 }
00052 
00053 CString
00054 XSocketAddress::getWhat() const throw()
00055 {
00056     static const char* s_errorID[] = {
00057         "XSocketAddressUnknown",
00058         "XSocketAddressNotFound",
00059         "XSocketAddressNoAddress",
00060         "XSocketAddressUnsupported",
00061         "XSocketAddressBadPort"
00062     };
00063     static const char* s_errorMsg[] = {
00064         "unknown error for: %{1}:%{2}",
00065         "address not found for: %{1}",
00066         "no address for: %{1}",
00067         "unsupported address for: %{1}",
00068         "invalid port"              // m_port may not be set to the bad port
00069     };
00070     return format(s_errorID[m_error], s_errorMsg[m_error],
00071                                 m_hostname.c_str(), 
00072                                 CStringUtil::print("%d", m_port).c_str());
00073 }
00074 
00075 
00076 //
00077 // XSocketIOClose
00078 //
00079 
00080 CString
00081 XSocketIOClose::getWhat() const throw()
00082 {
00083     return format("XSocketIOClose", "close: %{1}", what());
00084 }
00085 
00086 
00087 //
00088 // XSocketBind
00089 //
00090 
00091 CString
00092 XSocketBind::getWhat() const throw()
00093 {
00094     return format("XSocketBind", "cannot bind address: %{1}", what());
00095 }
00096 
00097 
00098 //
00099 // XSocketConnect
00100 //
00101 
00102 CString
00103 XSocketConnect::getWhat() const throw()
00104 {
00105     return format("XSocketConnect", "cannot connect socket: %{1}", what());
00106 }
00107 
00108 
00109 //
00110 // XSocketCreate
00111 //
00112 
00113 CString
00114 XSocketCreate::getWhat() const throw()
00115 {
00116     return format("XSocketCreate", "cannot create socket: %{1}", what());
00117 }

Generated on Tue Jun 18 2013 00:00:06 for Synergy by  doxygen 1.7.1