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
20#pragma pack(push, 8)
21#include <winsock.h>
22#pragma pack(pop)
23
24
25namespace owl {
26
27#include <owl/preclass.h>
28
29
30//
31/// \class TSocketAddress
32// ~~~~~ ~~~~~~~~~~~~~~
33/// The TSocketAddress class stores a Winsock socket address. This class is much
34/// like the sockaddr class; in fact, it is a subclass of sockaddr. Note that the
35/// TSocketAddress class does not store Internet (IP) addresses specifically. It
36/// stores generic socket addresses. The TINetSocketAddress class is used to store
37/// Internet addresses.
38///
39/// TSocketAddress normally stores its data in network byte ordering, as opposed to host byte ordering.
40//
41class _OWLCLASS TSocketAddress : public sockaddr {
42 public:
44 TSocketAddress(const sockaddr& src);
47
48 TSocketAddress& operator =(const sockaddr& src);
49 friend bool operator ==(const TSocketAddress& address1, const TSocketAddress& address2);
50
51 ushort GetFamily() const;
52 void SetFamily(ushort family);
53 void SetAddress(ushort family, const char* data, short dataLength);
54};
55
56//
57/// \class TINetSocketAddress
58// ~~~~~ ~~~~~~~~~~~~~~~~~~
59/// The TINetSocketAddress class encapsulates a Winsock Internet address. This
60/// class stores a complete Internet address, which includes an address family, a
61/// port, and a 32 bit (4 byte) IP address. The Internet address-specific
62/// information is stored in the sa_data field of the sockaddr.
63///
64/// \todo What about IPv6?
65//
67 public:
68
69 /// TINetClass is an enumeration that specifies which network class it belongs to.
70 /// There are three network classes: class A, class B, and class C. The classes
71 /// determine how many possible hosts there are on the network. Note that these
72 /// classes are the same when programming Windows Sockets.
73 ///
74 /// An address resolves to a 32-bit value. Each class has a different encoding scheme.
75 //
77 ClassA, ///< A class net addressing
78 ClassB, ///< B class net addressing
79 ClassC, ///< C class net addressing
80 ClassUnknown ///< Unknown class net addressing
81 };
82
84 TINetSocketAddress(const sockaddr& src);
89
90 TINetSocketAddress& operator =(const sockaddr& src);
91 operator sockaddr_in() const;
92
93 TINetClass GetClass() const;
94 ushort GetPort() const;
95 ulong GetNetworkAddress() const;
96 ulong GetNetwork() const;
97 ulong GetNetwork(ulong subnet) const;
98 ulong GetNode() const;
99 ulong GetNode(ulong subnet) const;
100 void SetAddress(ushort newFamily, ushort newPort, ulong newAddress);
101 void SetPort(ushort port);
102 void SetNetworkAddress(ulong address);
103 void SetNetworkAddress(const char* addressDottedDecimal);
104 void SetFiller();
105
106 static ulong ConvertAddress(const char * address);
107 static char * ConvertAddress(ulong address);
108 static short IsAddressDottedDecimal(const char * address);
109};
110
111#include <owl/posclass.h>
112
113//----------------------------------------------------------------------------
114// Inline implementations
115//
116
117//
118/// Returns the family of addressing this address belongs to.
119//
120inline ushort
122{
123 return sa_family;
124}
125
126//
127/// Sets the family of addressing this address belongs to.
128//
129inline void
134
135//
136/// This function converts this address to the sockaddr_in structure.
137//
138inline
139TINetSocketAddress::operator sockaddr_in() const
140{
141 return *((sockaddr_in*)this);
142}
143
144//
145/// This function returns the network ID masked with the subnet.
146//
147inline ulong
152
153//
154/// This function returns the node of this address.
155//
156inline ulong
161
162} // OWL namespace
163
164
165#endif // OWL_WSKADDR_H
The TINetSocketAddress class encapsulates a Winsock Internet address.
Definition wskaddr.h:66
TINetClass
TINetClass is an enumeration that specifies which network class it belongs to.
Definition wskaddr.h:76
@ ClassB
B class net addressing.
Definition wskaddr.h:78
@ ClassA
A class net addressing.
Definition wskaddr.h:77
@ ClassC
C class net addressing.
Definition wskaddr.h:79
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:41
void SetFamily(ushort family)
Sets the family of addressing this address belongs to.
Definition wskaddr.h:130
ushort GetFamily() const
Returns the family of addressing this address belongs to.
Definition wskaddr.h:121
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.