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
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
20namespace 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//
38 public:
42 int type = SOCK_DGRAM, int protocol = 0);
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 //
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//
77 public:
78 /// Current status of this stream socket
79 //
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
90 int Type = SOCK_STREAM, int protocol = 0);
92
94 int Connect();
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//
127inline TDatagramSocket&
133
134//
135/// This function sets the maximum size of the send packet buffer.
136//
137inline void
142
143
144} // OWL namespace
145
146
147
148#endif // OWL_WSKSOCKD_H
The TDatagramSocket encapsulates a Winsock datagram (non-reliable, packet-based) socket.
Definition wsksockd.h:37
TDatagramSocket & operator=(TDatagramSocket &newDatagramSocket1)
Copies the datagram socket connection information.
Definition wsksockd.h:128
void SetMaxPacketSendSize(int size)
This function sets the maximum size of the send packet buffer.
Definition wsksockd.h:138
static int MaxPacketSendSize
Defined by the WSAStartup() call return information (WSAData).
Definition wsksockd.h:55
The TSocketAddress class stores a Winsock socket address.
Definition wskaddr.h:38
TSocket encapsulates the basic attributes of a socket.
Definition wsksock.h:102
TSocket & operator=(TSocket &newSocket)
Definition wsksock.cpp:120
The TStreamSocket encapsulates a Winsock stream socket.
Definition wsksockd.h:76
TConnectStatus
Current status of this stream socket.
Definition wsksockd.h:80
@ ConnectPending
Connection is pending.
Definition wsksockd.h:82
@ Connected
Currently connected.
Definition wsksockd.h:83
@ NotConnected
This socket is not used.
Definition wsksockd.h:81
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
#define _OWLCLASS
Definition defs.h:338
Winsock for OWL subsystem.
#define N_DEF_MAX_QUEUED_CONNECTIONS
Definition wsksockd.h:61