OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
wskaddr.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_WSKADDR_H)
11#define OWL_WSKADDR_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 <winsock.h>
20
21
22namespace owl {
23
24#include <owl/preclass.h>
25
26
27//
28/// \class TSocketAddress
29// ~~~~~ ~~~~~~~~~~~~~~
30/// The TSocketAddress class stores a Winsock socket address. This class is much
31/// like the sockaddr class; in fact, it is a subclass of sockaddr. Note that the
32/// TSocketAddress class does not store Internet (IP) addresses specifically. It
33/// stores generic socket addresses. The TINetSocketAddress class is used to store
34/// Internet addresses.
35///
36/// TSocketAddress normally stores its data in network byte ordering, as opposed to host byte ordering.
37//
38class _OWLCLASS TSocketAddress : public sockaddr {
39 public:
41 TSocketAddress(const sockaddr& src);
44
45 TSocketAddress& operator =(const sockaddr& src);
46 friend bool operator ==(const TSocketAddress& address1, const TSocketAddress& address2);
47
48 ushort GetFamily() const;
49 void SetFamily(ushort family);
50 void SetAddress(ushort family, const char* data, short dataLength);
51};
52
53//
54/// \class TINetSocketAddress
55// ~~~~~ ~~~~~~~~~~~~~~~~~~
56/// The TINetSocketAddress class encapsulates a Winsock Internet address. This
57/// class stores a complete Internet address, which includes an address family, a
58/// port, and a 32 bit (4 byte) IP address. The Internet address-specific
59/// information is stored in the sa_data field of the sockaddr.
60///
61/// \todo What about IPv6?
62//
64 public:
65
66 /// TINetClass is an enumeration that specifies which network class it belongs to.
67 /// There are three network classes: class A, class B, and class C. The classes
68 /// determine how many possible hosts there are on the network. Note that these
69 /// classes are the same when programming Windows Sockets.
70 ///
71 /// An address resolves to a 32-bit value. Each class has a different encoding scheme.
72 //
74 ClassA, ///< A class net addressing
75 ClassB, ///< B class net addressing
76 ClassC, ///< C class net addressing
77 ClassUnknown ///< Unknown class net addressing
78 };
79
81 TINetSocketAddress(const sockaddr& src);
86
87 TINetSocketAddress& operator =(const sockaddr& src);
88 operator sockaddr_in() const;
89
90 TINetClass GetClass() const;
91 ushort GetPort() const;
92 ulong GetNetworkAddress() const;
93 ulong GetNetwork() const;
94 ulong GetNetwork(ulong subnet) const;
95 ulong GetNode() const;
96 ulong GetNode(ulong subnet) const;
97 void SetAddress(ushort newFamily, ushort newPort, ulong newAddress);
98 void SetPort(ushort port);
99 void SetNetworkAddress(ulong address);
100 void SetNetworkAddress(const char* addressDottedDecimal);
101 void SetFiller();
102
103 static ulong ConvertAddress(const char * address);
104 static char * ConvertAddress(ulong address);
105 static short IsAddressDottedDecimal(const char * address);
106};
107
108#include <owl/posclass.h>
109
110//----------------------------------------------------------------------------
111// Inline implementations
112//
113
114//
115/// Returns the family of addressing this address belongs to.
116//
117inline ushort
119{
120 return sa_family;
121}
122
123//
124/// Sets the family of addressing this address belongs to.
125//
126inline void
131
132//
133/// This function converts this address to the sockaddr_in structure.
134//
135inline
136TINetSocketAddress::operator sockaddr_in() const
137{
138 return *((sockaddr_in*)this);
139}
140
141//
142/// This function returns the network ID masked with the subnet.
143//
144inline ulong
149
150//
151/// This function returns the node of this address.
152//
153inline ulong
158
159} // OWL namespace
160
161
162#endif // OWL_WSKADDR_H
The TINetSocketAddress class encapsulates a Winsock Internet address.
Definition wskaddr.h:63
TINetClass
TINetClass is an enumeration that specifies which network class it belongs to.
Definition wskaddr.h:73
@ ClassB
B class net addressing.
Definition wskaddr.h:75
@ ClassA
A class net addressing.
Definition wskaddr.h:74
@ ClassC
C class net addressing.
Definition wskaddr.h:76
ulong GetNetworkAddress() const
This function returns an IP binary address in network byte ordering.
Definition wskaddr.cpp:242
ulong GetNetwork() const
This function returns 0 if the network cannot be determined.
Definition wskaddr.cpp:252
ulong GetNode() const
This function returns the node component of the address with the subnet masked out.
Definition wskaddr.cpp:275
The TSocketAddress class stores a Winsock socket address.
Definition wskaddr.h:38
void SetFamily(ushort family)
Sets the family of addressing this address belongs to.
Definition wskaddr.h:127
ushort GetFamily() const
Returns the family of addressing this address belongs to.
Definition wskaddr.h:118
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned short ushort
Definition number.h:24
unsigned long ulong
Definition number.h:26
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
Main header of the Winsock OWL subsystem.