OWLNext
7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
wskhostm.h
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectWindows
3
// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// Winsock for OWL subsystem.
7
/// Based on work by Paul Pedriana, 70541.3223@compuserve.com
8
//----------------------------------------------------------------------------
9
10
#if !defined(OWL_WSKHOSTM_H)
11
#define OWL_WSKHOSTM_H
12
13
#include <
owl/private/defs.h
>
14
#if defined(BI_HAS_PRAGMA_ONCE)
15
# pragma once
16
#endif
17
18
#include <
owl/defs.h
>
19
#include <
owl/window.h
>
20
#include <
owl/winsock.h
>
21
22
23
namespace
owl
{
24
25
//
26
// Forward ref.
27
//
28
class
_OWLCLASS
TSocketAddress;
29
30
#define WINSOCK_NOERROR (int)0
31
#define WINSOCK_ERROR (int)SOCKET_ERROR
32
33
//
34
// Supposedly in RFC 883.
35
//
36
#define N_MAX_HOST_NAME 128
37
#define MSG_HOST_INFO_NOTIFY ((UINT)(WM_USER+303))
38
39
class
_OWLCLASS
THostInfoManager;
40
41
#include <
owl/preclass.h
>
42
43
//
44
/// \class THostInfoWindow
45
// ~~~~~ ~~~~~~~~~~~~~~~
46
/// A private class created by THostInfoManager to catch WinSock messages.
47
//
48
class
_OWLCLASS
THostInfoWindow
:
public
TWindow
{
49
public
:
50
THostInfoWindow
(
THostInfoManager
*
hostInfoManagerParent
);
51
52
TResult
DoNotification(
TParam1
,
TParam2
);
53
54
public_data
:
55
/// Object to notify of Winsock events
56
//
57
THostInfoManager
* HostInfoManagerParent;
58
59
DECLARE_RESPONSE_TABLE
(
THostInfoWindow
);
60
};
61
62
//
63
/// \class THostEntry
64
// ~~~~~ ~~~~~~~~~~
65
/// THostEntry encapsulates the attributes of a host (hostent).
66
//
67
class
_OWLCLASS
THostEntry
:
public
hostent {
68
public
:
69
THostEntry
();
70
71
int
GetAddressCount();
72
ulong
GetINetAddress();
73
74
/// An internet addressing -specific function.
75
//
76
ulong
GetNthINetAddress(
int
nIndex
= 0);
77
};
78
79
//
80
/// \class THostInfoManager
81
// ~~~~~ ~~~~~~~~~~~~~~~~
82
/// The THostInfoManager class (and its friend class THostInfoWindow) encapsulate
83
/// the Winsock database functions gethostbyname(), gethostbyaddr(), and
84
/// gethostname(). These blocking (gethostby...) and non-blocking (gethostname)
85
/// functions return information about the host in a hostent structure.
86
//
87
class
_OWLCLASS
THostInfoManager
{
88
public
:
89
THostInfoManager
();
90
virtual
~THostInfoManager
();
91
92
int
GetLastError();
93
int
GetHostName(
char
*
name
,
int
nameLength
=
N_MAX_HOST_NAME
);
94
int
GetHostAddress(
char
*
szHostAddress
,
const
char
*
szHostName
);
95
int
GetHostAddress(
TSocketAddress
&
sAddress
,
const
char
*
szHostName
);
96
int
GetHostInfo(
THostEntry
*&
hEntry
,
const
TSocketAddress
&
sAddress
);
97
int
GetHostInfo(
THostEntry
*&
hEntry
,
const
char
*
szName
);
98
int
GetHostInfoAsync(
HANDLE
&
hTheHostRequest
,
TSocketAddress
&
sAddress
);
99
int
GetHostInfoAsync(
HANDLE
&
hTheHostRequest
,
char
*
szName
);
100
int
GetHostInfoAsync(
TWindow
&
wndNotify
,
HANDLE
&
hTheHostRequest
,
101
TSocketAddress
&
sAddress
,
uint
nMessage
=
MSG_HOST_INFO_NOTIFY
,
102
char
*
chBuffer
= 0);
103
int
GetHostInfoAsync(
TWindow
&
wndNotify
,
HANDLE
&
hTheHostRequest
,
104
char
*
szName
,
uint
nMessage
=
MSG_HOST_INFO_NOTIFY
,
105
char
*
chBuffer
= 0);
106
int
CancelHostRequest(
HANDLE
hTheHostRequest
= 0);
107
short
GetHostRequestCompleted();
108
static
int
HostEntryToAddress(
THostEntry
*
hEntry
,
char
*
szAddress
);
109
static
int
HostEntryToAddress(
THostEntry
*
hEntry
,
TSocketAddress
&
sAddress
);
110
111
// !CQ public?
112
// Set to point to HostInfoBuffer.
113
//
114
public_data
:
115
THostEntry
* HostEntry;
116
117
protected
:
118
bool
HostRequestCompleted
;
///< Flag if host completed last request
119
HANDLE
HostRequest
;
///< Handle of host to get info about
120
int
LastError
;
///< Last error code
121
char
HostInfoBuffer[
MAXGETHOSTSTRUCT
];
///< Used for calls to WSAAsync...()
122
THostInfoWindow
HostWindow
;
///< Hidden window to catch notifications
123
124
void
SetHostRequestCompleted(
int
error
);
125
126
friend
class
THostInfoWindow
;
127
};
128
129
#include <
owl/posclass.h
>
130
131
//----------------------------------------------------------------------------
132
// Inline implementations
133
//
134
135
//
136
/// Returns the Internet address of the host.
137
//
138
inline
ulong
139
THostEntry::GetINetAddress
()
140
{
141
return
GetNthINetAddress
(0);
142
}
143
144
//
145
/// This function returns the last error code.
146
//
147
inline
int
148
THostInfoManager::GetLastError
()
149
{
150
return
LastError
;
151
}
152
153
//
154
/// This function returns true if the host completed the last requested transaction.
155
/// \todo really return a short? HostRequestCompleted is bool
156
//
157
inline
short
158
THostInfoManager::GetHostRequestCompleted
()
159
{
160
return
HostRequestCompleted
;
161
}
162
163
}
// OWL namespace
164
165
166
#endif
// OWL_WSKHOSTM_H
VarType
Definition
safearray.h:14
owl::THostEntry
THostEntry encapsulates the attributes of a host (hostent).
Definition
wskhostm.h:67
owl::THostEntry::GetINetAddress
ulong GetINetAddress()
Returns the Internet address of the host.
Definition
wskhostm.h:139
owl::THostEntry::GetNthINetAddress
ulong GetNthINetAddress(int nIndex=0)
An internet addressing -specific function.
Definition
wskhostm.cpp:84
owl::THostInfoManager
The THostInfoManager class (and its friend class THostInfoWindow) encapsulate the Winsock database fu...
Definition
wskhostm.h:87
owl::THostInfoManager::GetHostRequestCompleted
short GetHostRequestCompleted()
This function returns true if the host completed the last requested transaction.
Definition
wskhostm.h:158
owl::THostInfoManager::HostRequest
HANDLE HostRequest
Handle of host to get info about.
Definition
wskhostm.h:119
owl::THostInfoManager::LastError
int LastError
Last error code.
Definition
wskhostm.h:120
owl::THostInfoManager::HostRequestCompleted
bool HostRequestCompleted
Flag if host completed last request.
Definition
wskhostm.h:118
owl::THostInfoManager::HostWindow
THostInfoWindow HostWindow
Hidden window to catch notifications.
Definition
wskhostm.h:122
owl::THostInfoManager::GetLastError
int GetLastError()
This function returns the last error code.
Definition
wskhostm.h:148
owl::THostInfoWindow
A private class created by THostInfoManager to catch WinSock messages.
Definition
wskhostm.h:48
owl::TSocketAddress
The TSocketAddress class stores a Winsock socket address.
Definition
wskaddr.h:38
owl::TWindow
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition
window.h:414
DECLARE_RESPONSE_TABLE
#define DECLARE_RESPONSE_TABLE(cls)
Definition
eventhan.h:436
owl
Object Windows Library (OWLNext Core)
Definition
animctrl.h:22
owl::ulong
unsigned long ulong
Definition
number.h:26
owl::TParam2
LPARAM TParam2
Second parameter type.
Definition
dispatch.h:55
owl::TParam1
WPARAM TParam1
First parameter type.
Definition
dispatch.h:54
owl::uint
unsigned int uint
Definition
number.h:25
defs.h
General definitions used by all ObjectWindows programs.
public_data
#define public_data
Definition
defs.h:207
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
window.h
Base window class TWindow definition, including HWND encapsulation.
winsock.h
Main header of the Winsock OWL subsystem.
MSG_HOST_INFO_NOTIFY
#define MSG_HOST_INFO_NOTIFY
Definition
wskhostm.h:37
N_MAX_HOST_NAME
#define N_MAX_HOST_NAME
Definition
wskhostm.h:36
include
owl
wskhostm.h
Generated by
1.10.0