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
wskservm.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_WSKSERVM_H)
11#define OWL_WSKSERVM_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 <winsock.h>
21
22
23namespace owl {
24
25#define WINSOCK_NOERROR (int)0
26#define WINSOCK_ERROR (int)SOCKET_ERROR
27
28//
29// Is supposedly in RFC 883.
30//
31#define N_MAX_SERVICE_NAME 128
32#define MSG_SERVICE_NOTIFY ((UINT)(WM_USER+302))
33
34class _OWLCLASS TServiceManager;
35
36#include <owl/preclass.h>
37
38//
39/// \class TServiceWindow
40// ~~~~~ ~~~~~~~~~~~~~~
41/// TServiceWindow is a private class created by the TServiceManager to catch
42/// notifications.
43//
45 public:
47
48 protected: // CQ add this?
49 /// Object to pass notifications
50 //
52
53 TResult DoNotification(TParam1, TParam2);
54
56};
57
58//
59/// \class TServiceEntry
60// ~~~~~ ~~~~~~~~~~~~~
61/// Encapsulates information about a service.
62//
63class _OWLCLASS TServiceEntry : public servent {
64 public:
66};
67
68//
69/// \class TServiceManager
70// ~~~~~ ~~~~~~~~~~~~~~~
71/// The TServiceManager class (and its friend class TServiceWindow) encapsulate the
72/// Winsock database functions getservbyname(), getservbyport(),
73/// WSAAsyncGetServByName(), and WSAAsyncGetServByPort(). These blocking (get...)
74/// and non-blocking (WSA...) functions return information about the service name,
75/// port, and protocol when given only a service name or a port.
76//
78 public:
80 virtual ~TServiceManager();
81
82 int GetLastError();
83 int GetLastServiceCompletion();
84 int GetService(TServiceEntry*& sEntry, uint16 nPort, const char* szProtocol = 0);
85 int GetService(TServiceEntry*& sEntry, const char* szName,
86 const char* szProtocol = 0);
87 int GetServicePort(char* szName, uint16& nPort, const char* szProtocol = 0);
88 int GetServiceName(uint16 nPort, char* szName, const char* szProtocol = 0);
89 int GetServiceAsync(HANDLE& hService, uint16 nPort, const char* szProtocol = 0);
90 int GetServiceAsync(HANDLE& hService, char* szName, const char* szProtocol = 0);
91 int GetServiceAsync(TWindow& wndNotify, HANDLE& hService, uint16 nPort,
92 const char* szProtocol = 0, uint nMessage = MSG_SERVICE_NOTIFY,
93 char* chBuffer = 0);
94 int GetServiceAsync(TWindow& wndNotify, HANDLE& hService, char* szName,
95 const char* szProtocol = 0, uint nMessage = MSG_SERVICE_NOTIFY,
96 char* chBuffer = 0);
97 int CancelServiceRequest(HANDLE hService = 0);
98 bool GetServiceRequestCompleted();
99
101 /// Set to point to chServiceBuffer.
102 //
103 TServiceEntry* ServiceEntry;
104
105 protected:
106 int LastError; ///< Last error code
107 int OutstandingServiceRequests; ///< Count of total requests done by myself that haven't completed yet.
108 bool LastServiceRequestCompleted; ///< Is the last request done?
109 char ServiceBuffer[MAXGETHOSTSTRUCT]; ///< Used for calls to WSAAsync...()
110 HANDLE LastServiceRequest; ///< Handle of last service request
111 TServiceWindow Window; ///< Private window for catching notification
112
113 void ServiceCompleted(int nError);
114
115 friend class TServiceWindow;
116};
117
118#include <owl/posclass.h>
119
120
121//----------------------------------------------------------------------------
122// Inline implementations
123//
124
125//
126/// This function returns the last error code.
127//
128inline int
133
134//
135/// This function returns the last service completion.
136/// \todo why int return type?
137//
138inline int
143
144//
145/// This function returns true if the last service requested has been completed.
146//
147inline bool
152
153} // OWL namespace
154
155
156#endif // OWL_WSKSERVM_H
Encapsulates information about a service.
Definition wskservm.h:63
The TServiceManager class (and its friend class TServiceWindow) encapsulate the Winsock database func...
Definition wskservm.h:77
HANDLE LastServiceRequest
Handle of last service request.
Definition wskservm.h:110
bool LastServiceRequestCompleted
Is the last request done?
Definition wskservm.h:108
int GetLastServiceCompletion()
This function returns the last service completion.
Definition wskservm.h:139
TServiceWindow Window
Private window for catching notification.
Definition wskservm.h:111
int GetLastError()
This function returns the last error code.
Definition wskservm.h:129
bool GetServiceRequestCompleted()
This function returns true if the last service requested has been completed.
Definition wskservm.h:148
int OutstandingServiceRequests
Count of total requests done by myself that haven't completed yet.
Definition wskservm.h:107
int LastError
Last error code.
Definition wskservm.h:106
TServiceWindow is a private class created by the TServiceManager to catch notifications.
Definition wskservm.h:44
TServiceManager * ServiceManagerParent
Object to pass notifications.
Definition wskservm.h:51
DECLARE_RESPONSE_TABLE(TServiceWindow)
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
unsigned short uint16
Definition number.h:33
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_SERVICE_NOTIFY
Definition wskservm.h:32