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