~nobuto/ubuntu/natty/synergy/merge-from-experimental

« back to all changes in this revision

Viewing changes to lib/net/XSocket.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Lutz
  • Date: 2003-10-31 19:36:30 UTC
  • Revision ID: james.westby@ubuntu.com-20031031193630-knbv79x5az7qh49y
Tags: upstream-1.0.14
ImportĀ upstreamĀ versionĀ 1.0.14

Show diffs side-by-side

added added

removed removed

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