forked from RestKit/RestKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRKPortCheck.h
More file actions
83 lines (65 loc) · 2.47 KB
/
Copy pathRKPortCheck.h
File metadata and controls
83 lines (65 loc) · 2.47 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// RKPortCheck.h
// RestKit
//
// Created by Blake Watters on 5/10/12.
// Copyright (c) 2012 RestKit. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
The RKPortCheck class provides a simple interface for quickly testing
the availability of a listening TCP port on a remote host by IP Address or
Hostname.
*/
@interface RKPortCheck : NSObject
///-----------------------------------------------------------------------------
/// @name Creating a Port Check
///-----------------------------------------------------------------------------
/**
Initializes the receiver with a given hostname or IP address as a string
and a numeric TCP port number.
@param hostNameOrIPAddress A string containing the hostname or IP address to check.
@param port The TCP port on the remote host to check for a listening server on.
@return The receiver, initialized with host and port.
*/
- (id)initWithHost:(NSString *)hostNameOrIPAddress port:(NSUInteger)port;
///-----------------------------------------------------------------------------
/// @name Accessing Host and Port
///-----------------------------------------------------------------------------
/**
The hostname or IP address the receiver is checking.
*/
@property (nonatomic, retain, readonly) NSString *host;
/**
The TCP port to check for a listening server on.
*/
@property (nonatomic, assign, readonly) NSUInteger port;
///-----------------------------------------------------------------------------
/// @name Running the Check
///-----------------------------------------------------------------------------
/**
Runs the check by creating a socket and attempting to connect to the
target host and port via TCP. The
*/
- (void)run;
///-----------------------------------------------------------------------------
/// @name Inspecting Port Accessibility
///-----------------------------------------------------------------------------
/**
Returns a Boolean value indicating if the check has been run.
@return YES if the check has been run, otherwise NO.
*/
- (BOOL)hasRun;
/**
Returns a Boolean value indicating if the host and port the receiver checked
is open and listening for incoming connections.
@return YES if the port on the remote host is open, otherwise NO.
*/
- (BOOL)isOpen;
/**
Returns a Boolean value indicating if the host and port the receiver checked
is NOT open and listening for incoming connections.
@return YES if the port on the remote host is closed, otherwise NO.
*/
- (BOOL)isClosed;
@end