OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
wsksockd.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_WSKSOCKD_H)
11
#define OWL_WSKSOCKD_H
12
13
#include <
owl/private/defs.h
>
14
#if defined(BI_HAS_PRAGMA_ONCE)
15
# pragma once
16
#endif
17
18
#include <
owl/wsksock.h
>
19
20
namespace
owl
{
21
22
#include <
owl/preclass.h
>
23
24
//
25
/// \class TDatagramSocket
26
// ~~~~~ ~~~~~~~~~~~~~~~
27
/// The TDatagramSocket encapsulates a Winsock datagram (non-reliable, packet-based)
28
/// socket. While Winsock version 1.1 is for TCP/IP, Winsock 2.0 and later will
29
/// likely support other protocols. The TDatagramSocket Windows Socket Class class
30
/// is designed to be as forward compatible with Winsock 2.0 as is currently
31
/// possible; it contains no TCP/UDP-specific calls, and uses TSocketAddresses and
32
/// not TINetSocketAddresses.
33
/// \note Unlike stream sockets, datagram sockets are unreliable - i.e. the
34
/// bi-directional flow of data is not guaranteed to be sequenced and/or
35
/// unduplicated.
36
//
37
class
_OWLCLASS
TDatagramSocket
:
public
TSocket
{
38
public
:
39
TDatagramSocket
();
40
TDatagramSocket
(SOCKET& newS);
41
TDatagramSocket
(
TSocketAddress
& newSocketAddress,
int
addressFormat = PF_INET,
42
int
type = SOCK_DGRAM,
int
protocol = 0);
43
TDatagramSocket
& operator =(
TDatagramSocket
& newDatagramSocket1);
44
45
void
SetMaxPacketSendSize
(
int
size);
46
int
Read
(
char
* data,
int
& charsToRead,
TSocketAddress
& sAddress);
47
int
Write
(
char
* data,
int
& charsToWrite,
TSocketAddress
& outSocketAddress,
48
bool
becomeOwnerOfData =
true
,
bool
copyData =
true
);
49
int
Write
(
char
* data,
int
& charsToWrite,
bool
becomeOwnerOfData =
true
,
50
bool
copyData =
true
);
51
52
protected
:
53
/// Defined by the WSAStartup() call return information (WSAData).
54
//
55
static
int
MaxPacketSendSize
;
56
57
int
DoReadNotification
(
const
SOCKET& s,
int
error);
58
int
DoWriteNotification
(
const
SOCKET& s,
int
error);
59
};
60
61
#define N_DEF_MAX_QUEUED_CONNECTIONS 5
62
63
//
64
/// \class TStreamSocket
65
// ~~~~~ ~~~~~~~~~~~~~
66
/// The TStreamSocket encapsulates a Winsock stream socket. While Winsock version
67
/// 1.1 is for TCP/IP, Winsock 2.0 and later will likely support other protocols.
68
/// The TStreamSocket Windows Socket Class class is designed to be as
69
/// forward-compatible with Winsock 2.0 as is currently possible; it contains no
70
/// TCP/UDP-specific calls, and uses TSocketAddress and not TINetSocketAddress (IP
71
/// addresses).
72
/// In addition to supporting standard data reading and writing, the TStreamSocket
73
/// also supports out-of-band reading and writing. Winsock calls such as accept()
74
/// and listen() are implemented.
75
//
76
class
_OWLCLASS
TStreamSocket
:
public
TSocket
{
77
public
:
78
/// Current status of this stream socket
79
//
80
enum
TConnectStatus
{
81
NotConnected
,
///< This socket is not used
82
ConnectPending
,
///< Connection is pending
83
Connected
,
///< Currently connected
84
Listening
///< Waiting for a connection
85
} ConnectStatus;
86
87
TStreamSocket
();
88
TStreamSocket
(SOCKET& newS);
89
TStreamSocket
(
TSocketAddress
& socketAddress,
int
addressFormat = PF_INET,
90
int
Type = SOCK_STREAM,
int
protocol = 0);
91
TStreamSocket
& operator =(
TStreamSocket
& src);
92
93
int
Listen(
int
nMaxQueuedConnections =
N_DEF_MAX_QUEUED_CONNECTIONS
);
94
int
Connect();
95
int
Connect(
TSocketAddress
& addressToConnectTo);
96
int
Accept(
TStreamSocket
& socket);
97
int
Accept(SOCKET& socket, sockaddr& sAddress);
98
99
int
Read(
char
* data,
int
& charsToRead);
100
int
Write(
char
* data,
int
& charsToWrite,
int
flags = 0,
101
bool
becomeOwnerOfData =
true
,
bool
copyData =
true
);
102
//Is the same as send func
103
int
ReadOOB(
char
* data,
int
& charsToRead);
104
int
WriteOOB(
char
* data,
int
& charsToWrite,
int
nFlags = MSG_OOB,
105
bool
becomeOwnerOfData =
true
,
bool
copyData =
true
);
106
//ORs nFlags w MSG_OOB.
107
108
protected
:
109
int
DoReadNotification(
const
SOCKET& s,
int
nError);
110
int
DoWriteNotification(
const
SOCKET& s,
int
nError);
111
int
DoOOBNotification(
const
SOCKET& s,
int
nError);
112
int
DoAcceptNotification(
const
SOCKET& s,
int
nError);
113
int
DoConnectNotification(
const
SOCKET& s,
int
nError);
114
int
DoCloseNotification(
const
SOCKET& s,
int
nError);
115
};
116
117
#include <
owl/posclass.h
>
118
119
120
//----------------------------------------------------------------------------
121
// Inline implementations
122
//
123
124
//
125
/// Copies the datagram socket connection information.
126
//
127
inline
TDatagramSocket&
128
TDatagramSocket::operator =
(
TDatagramSocket
& newDatagramSocket1)
129
{
130
TSocket::operator =
(newDatagramSocket1);
131
return
*
this
;
132
}
133
134
//
135
/// This function sets the maximum size of the send packet buffer.
136
//
137
inline
void
138
TDatagramSocket::SetMaxPacketSendSize
(
int
size)
139
{
140
MaxPacketSendSize
= size;
141
}
142
143
144
}
// OWL namespace
145
146
147
148
#endif
// OWL_WSKSOCKD_H
owl::TDatagramSocket::operator=
TDatagramSocket & operator=(TDatagramSocket &newDatagramSocket1)
Copies the datagram socket connection information.
Definition
wsksockd.h:128
owl::TDatagramSocket::SetMaxPacketSendSize
void SetMaxPacketSendSize(int size)
This function sets the maximum size of the send packet buffer.
Definition
wsksockd.h:138
owl::TDatagramSocket::MaxPacketSendSize
static int MaxPacketSendSize
Defined by the WSAStartup() call return information (WSAData).
Definition
wsksockd.h:55
owl::TDatagramSocket::TDatagramSocket
TDatagramSocket()
This function does nothing. It relies on TSocket to do all the work.
Definition
wsksockd.cpp:26
owl::TDatagramSocket::Read
int Read(char *data, int &charsToRead, TSocketAddress &sAddress)
This function reads the chars into the chData buffer, and removes the data from the queue.
Definition
wsksockd.cpp:67
owl::TDatagramSocket::DoReadNotification
int DoReadNotification(const SOCKET &s, int error)
This function is called whenever the socket receives a read notification.
Definition
wsksockd.cpp:138
owl::TDatagramSocket::Write
int Write(char *data, int &charsToWrite, TSocketAddress &outSocketAddress, bool becomeOwnerOfData=true, bool copyData=true)
This function puts the data in the queue and attempts to write the first item in the queue.
Definition
wsksockd.cpp:99
owl::TDatagramSocket::DoWriteNotification
int DoWriteNotification(const SOCKET &s, int error)
This function is called whenever the socket receives a write notification.
Definition
wsksockd.cpp:157
owl::TSocketAddress
The TSocketAddress class stores a Winsock socket address.
Definition
wskaddr.h:41
owl::TSocket::operator=
TSocket & operator=(TSocket &newSocket)
Definition
wsksock.cpp:120
owl::TSocket::TSocket
TSocket()
Default constructor for a socket.
Definition
wsksock.cpp:21
owl::TStreamSocket
The TStreamSocket encapsulates a Winsock stream socket.
Definition
wsksockd.h:76
owl::TStreamSocket::TStreamSocket
TStreamSocket()
This function calls TSocket constructor and initializes the state of the connection to not connected.
Definition
wsksockd.cpp:179
owl::TStreamSocket::TConnectStatus
TConnectStatus
Current status of this stream socket.
Definition
wsksockd.h:80
owl::TStreamSocket::ConnectPending
@ ConnectPending
Connection is pending.
Definition
wsksockd.h:82
owl::TStreamSocket::Connected
@ Connected
Currently connected.
Definition
wsksockd.h:83
owl::TStreamSocket::NotConnected
@ NotConnected
This socket is not used.
Definition
wsksockd.h:81
owl::TStreamSocket::Listening
@ Listening
Waiting for a connection.
Definition
wsksockd.h:84
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
wsksock.h
Winsock for OWL subsystem.
N_DEF_MAX_QUEUED_CONNECTIONS
#define N_DEF_MAX_QUEUED_CONNECTIONS
Definition
wsksockd.h:61
include
owl
wsksockd.h
Generated by
1.18.0