Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

XSocket.cpp

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

Generated on Fri Nov 6 00:21:15 2009 for synergy-plus by  doxygen 1.3.9.1