00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "XSocket.h"
00020 #include "CStringUtil.h"
00021
00022
00023
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
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"
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
00078
00079
00080 CString
00081 XSocketIOClose::getWhat() const throw()
00082 {
00083 return format("XSocketIOClose", "close: %{1}", what());
00084 }
00085
00086
00087
00088
00089
00090
00091 CString
00092 XSocketBind::getWhat() const throw()
00093 {
00094 return format("XSocketBind", "cannot bind address: %{1}", what());
00095 }
00096
00097
00098
00099
00100
00101
00102 CString
00103 XSocketConnect::getWhat() const throw()
00104 {
00105 return format("XSocketConnect", "cannot connect socket: %{1}", what());
00106 }
00107
00108
00109
00110
00111
00112
00113 CString
00114 XSocketCreate::getWhat() const throw()
00115 {
00116 return format("XSocketCreate", "cannot create socket: %{1}", what());
00117 }