Clapkit
Loading...
Searching...
No Matches
ckNetBaseSocket.h
Go to the documentation of this file.
1/*
2 *
3 * Clapkit
4 * ----------------------------------------------------------------------
5 * A wrapper for creating a 'generalized' app for Classic MacOS
6 * that (hopefully) can be ported easily to other platforms.
7 *
8 * CKNetBaseSocket
9 * ----------------------------------------------------------------------
10 * Implements the base socket for CKNetClient and CKNetServer
11 *
12 */
13
14#include "ckObject.h"
15#include "ckTypes.h"
16#include <Devices.h>
17#include <MacTCP.h>
18
19pascal void CKNBSNotify(StreamPtr stream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, struct ICMPReport* icmpMsg);
20pascal void CKNBSIOCompletion(TCPiopb* iopb);
21
22extern TCPNotifyUPP ckgNotifyUPP;
23extern TCPIOCompletionUPP ckgIOCompletionUPP;
24
30 public:
31 short csCode = 0;
32 bool result = false;
33 bool isWritten = false;
34 bool isRead = false;
35};
36
41class CKNetBaseSocket : public CKObject {
42
43 public:
46
47 virtual void Close();
48 void SetBufferSize(UInt16 size) {
49 if (this->__stream) {
50 return;
51 }
52 this->__mactcpBufferSize = size;
53 }
54 UInt16 GetBufferSize() {
55 return this->__mactcpBufferSize;
56 }
57
58 void Loop();
59
60 protected:
63
64 friend pascal void CKNBSNotify(StreamPtr, unsigned short, Ptr, unsigned short, struct ICMPReport*);
65 void __postNotifyEvent(unsigned short eventCode, unsigned short terminReason, struct ICMPReport* icmpMsg);
66
67 friend pascal void CKNBSIOCompletion(TCPiopb* iopb);
68 void __postIOCompletionEvent(unsigned short csCode, bool result);
69
70 protected:
71 UInt16 __mactcpBufferSize = 8192;
73 StreamPtr __stream = 0;
74 bool __hasStream = false;
75 bool __isConnected = false;
76
77 private:
78 bool __hasIntEvents = false;
79 bool __hasIncomingData = false;
80 bool __hasDisconnected = false;
81 CKNetBaseSocketEvtFromInterrupt __intEvents[32];
82 int __intEventsWriteIdx = 0;
83 int __intEventsReadIdx = 0;
84};
TCPIOCompletionUPP ckgIOCompletionUPP
Definition ckNetBaseSocket.cpp:21
pascal void CKNBSNotify(StreamPtr stream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, struct ICMPReport *icmpMsg)
Definition ckNetBaseSocket.cpp:238
TCPNotifyUPP ckgNotifyUPP
Definition ckNetBaseSocket.cpp:20
pascal void CKNBSIOCompletion(TCPiopb *iopb)
Definition ckNetBaseSocket.cpp:248
Defines the base of all TCP client/server sockets.
Definition ckNetBaseSocket.h:41
void SetBufferSize(UInt16 size)
Definition ckNetBaseSocket.h:48
virtual void Close()
Definition ckNetBaseSocket.cpp:45
~CKNetBaseSocket()
Definition ckNetBaseSocket.cpp:33
bool __isConnected
Definition ckNetBaseSocket.h:75
StreamPtr __stream
Definition ckNetBaseSocket.h:73
void __postNotifyEvent(unsigned short eventCode, unsigned short terminReason, struct ICMPReport *icmpMsg)
Definition ckNetBaseSocket.cpp:139
CKNetBaseSocket()
Definition ckNetBaseSocket.cpp:23
Ptr __mactcpBuffer
Definition ckNetBaseSocket.h:72
UInt16 __mactcpBufferSize
Definition ckNetBaseSocket.h:71
CKError __closeStream()
Definition ckNetBaseSocket.cpp:49
bool __hasStream
Definition ckNetBaseSocket.h:74
friend pascal void CKNBSNotify(StreamPtr, unsigned short, Ptr, unsigned short, struct ICMPReport *)
Definition ckNetBaseSocket.cpp:238
void __postIOCompletionEvent(unsigned short csCode, bool result)
Definition ckNetBaseSocket.cpp:156
UInt16 GetBufferSize()
Definition ckNetBaseSocket.h:54
friend pascal void CKNBSIOCompletion(TCPiopb *iopb)
Definition ckNetBaseSocket.cpp:248
void Loop()
Definition ckNetBaseSocket.cpp:170
CKError __openStream()
Definition ckNetBaseSocket.cpp:88
Defines the base class for all controls and objects.
Definition ckObject.h:43
int32_t CKError
Return type for functions that might return an error. Also see: CKPass and CKErrorCode.
Definition ckTypes.h:26
Defines a TCP event that's coming from the interrupt, to be added to the event handling queue.
Definition ckNetBaseSocket.h:29
bool isRead
Definition ckNetBaseSocket.h:34
bool isWritten
Definition ckNetBaseSocket.h:33
short csCode
Definition ckNetBaseSocket.h:31
bool result
Definition ckNetBaseSocket.h:32