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
wsksockm.cpp
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#include <owl/pch.h>
10#include <owl/defs.h>
11#include <owl/winsock.h>
12
13namespace owl {
14
16
17//
18/// Default constructor. Initializes all data members to 0.
19//
21{
22 wVersion = 0;
23 wHighVersion = 0;
24 szDescription[0] = 0;
25 szSystemStatus[0] = 0;
26 iMaxSockets = 0;
27 iMaxUdpDg = 0;
28 lpVendorInfo = 0;
29}
30
31//----------------------------------------------------------------------------
32
33//
34/// The SocketManager constructor takes a major and minor version as parameters.
35/// These version parameters are the Winsock versions that can be requested, as with
36/// WSAStartup() calls.
37//
39{
40 TWinSock::IsAvailable(); // !CQ throw an exception if not?
41
42 StartupCount = 0;
44 if (autoStartup)
45 Startup();
46}
47
48//
49/// The TSocketManager destructor cleans up after itself. Every time Startup() (same
50/// as WSAStartup()) is called, this destructor will call ShutDown (same as
51/// WSACleanup()).
52//
54{
55 while (StartupCount)
56 ShutDown(); // Call ShutDown() enough times to equal times Startup() was called.
57}
58
59//
60/// The ITSocketManager function does some initialization for the TSocketManager.
61/// This function is separate from the constructor so it can be called at any time
62/// to re-specify the desired major and minor versions before a call to Startup().
63/// nNewVersionMajor and nNewVersionMinor will be the values specified in the
64/// Winsock WSAStartup() call that TSocketManager::Startup() makes. The return value
65/// is TRUE or FALSE.
66//
73
74//
75/// The Startup() function is equivalent to the Winsock WSAStartup() function. This
76/// function fills out the TSocketManager's SocketInfo structure (same as a WSAData
77/// structure) with the return information. GetMaxSocketsAvailable(),
78/// GetVendorInfo(), Available(), GetMajorVersion(), GetMinorVersion(), or
79/// Information() functions can then be called to get the results of the call.
80//
95
96//
97/// The ShutDown() function is the equivalent to the Winsock WSACleanup() function.
98/// You can call this function if you want, but in its destructor, the
99/// TSocketManager will automatically call it once for every time Startup() was
100/// called. Of course, the TSocketManager cannot know about any independent
101/// WSAStartup() direct calls that are made.
102//
112
113} // OWL namespace
114/* ========================================================================== */
115
TSocketInfo()
Default constructor. Initializes all data members to 0.
Definition wsksockm.cpp:20
int Startup()
The Startup() function is equivalent to the Winsock WSAStartup() function.
Definition wsksockm.cpp:81
int LastError
Last error code.
Definition wsksockm.h:67
short StartupCount
Make sure to not overflow number of connects.
Definition wsksockm.h:69
void Init(short versionMajor=1, short versionMinor=1)
The ITSocketManager function does some initialization for the TSocketManager.
Definition wsksockm.cpp:67
TSocketManager(short versionMajor=1, short versionMinor=1, bool autoStartup=true)
The SocketManager constructor takes a major and minor version as parameters.
Definition wsksockm.cpp:38
int ShutDown()
The ShutDown() function is the equivalent to the Winsock WSACleanup() function.
Definition wsksockm.cpp:103
virtual ~TSocketManager()
The TSocketManager destructor cleans up after itself.
Definition wsksockm.cpp:53
short VersionMajor
Major verion number.
Definition wsksockm.h:71
TSocketInfo SocketInfo
Information about this WinSocket implementation.
Definition wsksockm.h:70
short VersionMinor
Minor verion number.
Definition wsksockm.h:72
static int WSAGetLastError(void)
Definition winsock.cpp:294
static int WSAStartup(uint16 versionRequested, LPWSADATA WSAData)
Definition winsock.cpp:273
static int WSACleanup(void)
Definition winsock.cpp:280
static bool IsAvailable(void)
Returns true if the DLL implementing WinSock is available and loaded, or false otherwise.
Definition winsock.cpp:422
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
uint8 HiUint8(LRESULT r)
Definition defs.h:282
unsigned short uint16
Definition number.h:33
uint8 LoUint8(LRESULT r)
Definition defs.h:276
General definitions used by all ObjectWindows programs.
Main header of the Winsock OWL subsystem.
#define WINSOCK_NOERROR
Definition wskhostm.h:30
#define WINSOCK_ERROR
Definition wskhostm.h:31