OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
23namespace owl {
24
25//
26// Forward ref.
27//
28class _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
39class _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//
49 public:
51
52 TResult DoNotification(TParam1, TParam2);
53
55 /// Object to notify of Winsock events
56 //
57 THostInfoManager* HostInfoManagerParent;
58
60};
61
62//
63/// \class THostEntry
64// ~~~~~ ~~~~~~~~~~
65/// THostEntry encapsulates the attributes of a host (hostent).
66//
67class _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//
88 public:
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,
102 char * chBuffer = 0);
103 int GetHostInfoAsync(TWindow& wndNotify, HANDLE& hTheHostRequest,
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 //
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//
138inline ulong
143
144//
145/// This function returns the last error code.
146//
147inline int
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//
157inline short
162
163} // OWL namespace
164
165
166#endif // OWL_WSKHOSTM_H
THostEntry encapsulates the attributes of a host (hostent).
Definition wskhostm.h:67
ulong GetINetAddress()
Returns the Internet address of the host.
Definition wskhostm.h:139
ulong GetNthINetAddress(int nIndex=0)
An internet addressing -specific function.
Definition wskhostm.cpp:84
The THostInfoManager class (and its friend class THostInfoWindow) encapsulate the Winsock database fu...
Definition wskhostm.h:87
short GetHostRequestCompleted()
This function returns true if the host completed the last requested transaction.
Definition wskhostm.h:158
HANDLE HostRequest
Handle of host to get info about.
Definition wskhostm.h:119
int LastError
Last error code.
Definition wskhostm.h:120
bool HostRequestCompleted
Flag if host completed last request.
Definition wskhostm.h:118
THostInfoWindow HostWindow
Hidden window to catch notifications.
Definition wskhostm.h:122
int GetLastError()
This function returns the last error code.
Definition wskhostm.h:148
A private class created by THostInfoManager to catch WinSock messages.
Definition wskhostm.h:48
The TSocketAddress class stores a Winsock socket address.
Definition wskaddr.h:38
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long ulong
Definition number.h:26
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
unsigned int uint
Definition number.h:25
General definitions used by all ObjectWindows programs.
#define public_data
Definition defs.h:207
#define _OWLCLASS
Definition defs.h:338
Base window class TWindow definition, including HWND encapsulation.
Main header of the Winsock OWL subsystem.
#define MSG_HOST_INFO_NOTIFY
Definition wskhostm.h:37
#define N_MAX_HOST_NAME
Definition wskhostm.h:36