blob: 636cdef560ea89238d3e0f1fca8b22bb9e67c1ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace BerkeleyDB {
/// <summary>
/// A class representing the address of a replication site used by Berkeley
/// DB HA.
/// </summary>
public class ReplicationHostAddress {
/// <summary>
/// The site's host identification string, generally a TCP/IP host name.
/// </summary>
public string Host;
/// <summary>
/// The port number on which the site is receiving.
/// </summary>
public uint Port;
/// <summary>
/// Instantiate a new, empty address
/// </summary>
public ReplicationHostAddress() { }
/// <summary>
/// Instantiate a new address, parsing the host and port from the given
/// string
/// </summary>
/// <param name="HostAndPort">A string in host:port format</param>
public ReplicationHostAddress(string HostAndPort) {
int sep = HostAndPort.IndexOf(':');
if (sep == -1)
throw new ArgumentException(
"Hostname and port must be separated by a colon.");
if (sep == 0)
throw new ArgumentException(
"Invalid hostname.");
try {
Port = UInt32.Parse(HostAndPort.Substring(sep + 1));
} catch {
throw new ArgumentException("Invalid port number.");
}
Host = HostAndPort.Substring(0, sep);
}
/// <summary>
/// Instantiate a new address
/// </summary>
/// <param name="Host">The site's host identification string</param>
/// <param name="Port">
/// The port number on which the site is receiving.
/// </param>
public ReplicationHostAddress(string Host, uint Port) {
this.Host = Host;
this.Port = Port;
}
}
}
|