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

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

synergy v1.3.1 sources (zip).

File size: 2.1 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#include "XSocket.h"
16#include "CStringUtil.h"
17
18//
19// XSocketAddress
20//
21
22XSocketAddress::XSocketAddress(EError error,
23 const CString& hostname, int port) throw() :
24 m_error(error),
25 m_hostname(hostname),
26 m_port(port)
27{
28 // do nothing
29}
30
31XSocketAddress::EError
32XSocketAddress::getError() const throw()
33{
34 return m_error;
35}
36
37CString
38XSocketAddress::getHostname() const throw()
39{
40 return m_hostname;
41}
42
43int
44XSocketAddress::getPort() const throw()
45{
46 return m_port;
47}
48
49CString
50XSocketAddress::getWhat() const throw()
51{
52 static const char* s_errorID[] = {
53 "XSocketAddressUnknown",
54 "XSocketAddressNotFound",
55 "XSocketAddressNoAddress",
56 "XSocketAddressUnsupported",
57 "XSocketAddressBadPort"
58 };
59 static const char* s_errorMsg[] = {
60 "unknown error for: %{1}:%{2}",
61 "address not found for: %{1}",
62 "no address for: %{1}",
63 "unsupported address for: %{1}",
64 "invalid port" // m_port may not be set to the bad port
65 };
66 return format(s_errorID[m_error], s_errorMsg[m_error],
67 m_hostname.c_str(),
68 CStringUtil::print("%d", m_port).c_str());
69}
70
71
72//
73// XSocketIOClose
74//
75
76CString
77XSocketIOClose::getWhat() const throw()
78{
79 return format("XSocketIOClose", "close: %{1}", what());
80}
81
82
83//
84// XSocketBind
85//
86
87CString
88XSocketBind::getWhat() const throw()
89{
90 return format("XSocketBind", "cannot bind address: %{1}", what());
91}
92
93
94//
95// XSocketConnect
96//
97
98CString
99XSocketConnect::getWhat() const throw()
100{
101 return format("XSocketConnect", "cannot connect socket: %{1}", what());
102}
103
104
105//
106// XSocketCreate
107//
108
109CString
110XSocketCreate::getWhat() const throw()
111{
112 return format("XSocketCreate", "cannot create socket: %{1}", what());
113}
Note: See TracBrowser for help on using the repository browser.