OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
winsock.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/// Main header of the Winsock OWL subsystem.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_WINSOCK_H)
10#define OWL_WINSOCK_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/module.h>
18#include <winsock.h>
19#include <owl/wskaddr.h>
20#include <owl/wsksock.h>
21#include <owl/wskerr.h>
22#include <owl/wskhostm.h>
23#include <owl/wsksockd.h>
24#include <owl/wsksockm.h>
25#include <owl/wskservm.h>
26
27
28namespace owl {
29
30#include <owl/preclass.h>
31
32//
33/// \class TWinSockDll
34// ~~~~~ ~~~~~~~~~~~
35/// The TWinSockDll class encapsulates the WinSock DLL (WINSOCK.DLL). It provides an
36/// easy method to dynamically test for the availability of the DLL and bind to its
37/// exported functions at runtime. By using the TWinSockDll class instead of direct
38/// calls to the WinSock DLL, ObjectWindows applications can provide the appropriate
39/// behaviour when running in an environment where the DLL is not available.
40///
41/// Each data member of the TWinSockDll class corresponds to the API with a similar
42/// name exposed by the WinSock DLL. For example, TWinSockDll::WSAStartup
43/// corresponds to the WSAStartup API exported by the WinSock DLL.
44///
45/// For more information about the members, consult
46/// the documentation about the corresponding API exposed by the WinSock DLL.
47//
49 public:
51
52 // Socket functions
53 //
54 static SOCKET accept(SOCKET s, struct sockaddr * addr,
55 int * addrLen);
56 static int bind(SOCKET s, struct sockaddr * addr, int nameLen);
57 static int closesocket(SOCKET s);
58 static int connect(SOCKET s, struct sockaddr * name, int nameLen);
59 static int getpeername(SOCKET s, struct sockaddr * name,
60 int * nameLen);
61 static int getsockname(SOCKET s, struct sockaddr * name,
62 int * nameLen);
63 static int getsockopt(SOCKET s, int level, int optName, char * optVal,
64 int * optLen);
65 static ulong _htonl(ulong hostLong);
66 static ushort _htons(ushort hostShort);
67 static ulong inet_addr(const char * cp);
68 static char * inet_ntoa(struct in_addr in);
69 static int ioctlsocket(SOCKET s, long cmd, ulong * argp);
70 static int listen(SOCKET s, int backlog);
71 static ulong _ntohl(ulong netLong);
72 static ushort _ntohs(ushort netShort);
73 static int recv(SOCKET s, char * buf, int len, int flags);
74 static int recvfrom(SOCKET s, char * buf, int len, int flags,
75 struct sockaddr * from, int* fromLen);
76 static int select(int nfds, struct fd_set * readfds,
77 struct fd_set * writefds,
78 struct fd_set * exceptfds,
79 const struct timeval * timeout);
80 static int send(SOCKET s, LPCSTR buf, int len, int flags);
81 static int sendto(SOCKET s, LPCSTR buf, int len, int flags,
82 const struct sockaddr * to, int toLen);
83 static int setsockopt(SOCKET s, int level, int optName,
84 LPCSTR optVal, int optLen);
85 static int shutdown(SOCKET s, int how);
86 static SOCKET socket(int af, int type, int protocol);
87
88 // Database functions
89 //
90 static struct hostent * gethostbyaddr(LPCSTR addr, int len, int type);
91 static struct hostent * gethostbyname(LPCSTR name);
92 static int gethostname(char * name, int nameLen);
93 static struct servent * getservbyname(LPCSTR name, LPCSTR proto);
94 static struct servent * getservbyport(int port, LPCSTR proto);
95 static struct protoent * getprotobyname(LPCSTR name);
96 static struct protoent * getprotobynumber(int proto);
97
98 // Microsoft Windows Extension functions
99 //
100 static int WSAStartup(uint16 versionRequested, LPWSADATA WSAData);
101 static int WSACleanup(void);
102 static void WSASetLastError(int error);
103 static int WSAGetLastError(void);
104 static BOOL WSAIsBlocking(void);
105 static int WSAUnhookBlockingHook(void);
106 static FARPROC WSASetBlockingHook(FARPROC blockFunc);
107 static int WSACancelBlockingCall(void);
108 static HANDLE WSAAsyncGetServByName(HWND hWnd, uint msg, LPCSTR name,
109 LPCSTR proto, char * buf, int bufLen);
110 static HANDLE WSAAsyncGetServByPort(HWND hWnd, uint msg, int port,
111 LPCSTR proto, char * buf, int bufLen);
112 static HANDLE WSAAsyncGetProtoByName(HWND hWnd, uint msg, LPCSTR name,
113 char * buf, int bufLen);
114 static HANDLE WSAAsyncGetProtoByNumber(HWND hWnd, uint msg, int number,
115 char * buf, int bufLen);
116 static HANDLE WSAAsyncGetHostByName(HWND hWnd, uint msg, LPCSTR name,
117 char * buf, int bufLen);
118 static HANDLE WSAAsyncGetHostByAddr(HWND hWnd, uint msg, LPCSTR addr,
119 int len, int type, char * buf, int bufLen);
120 static int WSACancelAsyncRequest(HANDLE hTaskHandle);
121 static int WSAAsyncSelect(SOCKET s, HWND hWnd, uint msg, long event);
122 static int WSARecvEx(SOCKET s, char * buf, int len, int * flags);
123
124 // Check for presence of Winsock DLL
125 //
126 static TModule& WinSockModule();
127 static bool IsAvailable();
128};
129
130//
131/// \class TWinSock
132// ~~~~~ ~~~~~~~~
133/// TWinSock is an alias for an instance of the TDllLoader template which ensures
134/// the underlying DLL is loaded and available. The 'IsAvailable' method (defined by
135/// the TDllLoader template) can be used to load the DLL. For example,
136/// \code
137/// if (TWinSock::IsAvailable()) {
138/// // DLL is loaded - Proceed with WinSock calls
139/// } else {
140/// // Error - Underlying DLL is not available.
141/// }
142/// \endcode
143//
144
146{
147 public:
148 static bool IsAvailable(void);
149 static TWinSockDll* Dll(void);
150};
151
152#include <owl/posclass.h>
153
154
155} // OWL namespace
156
157
158#endif // OWL_WSKDLL_H
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
The TWinSockDll class encapsulates the WinSock DLL (WINSOCK.DLL).
Definition winsock.h:48
TWinSock is an alias for an instance of the TDllLoader template which ensures the underlying DLL is l...
Definition winsock.h:146
Definition of class TModule.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned short ushort
Definition number.h:24
unsigned long ulong
Definition number.h:26
unsigned short uint16
Definition number.h:33
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338
Main header of the Winsock OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.
Winsock for OWL subsystem.