10#if !defined(OWL_WSKSOCK_H)
14#if defined(BI_HAS_PRAGMA_ONCE)
24#define WINSOCK_NOERROR (int)0
25#define WINSOCK_ERROR (int)SOCKET_ERROR
27#define N_DEF_MAX_READ_BUFFFER_SIZE 8192
32#define MSG_SOCKET_NOTIFY ((UINT)(WM_USER+301))
33#define FD_ALL (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT|FD_CLOSE)
81 static uint MsgSocketNotification;
115 int nNewType = SOCK_STREAM,
int nNewProtocol = 0);
118 operator SOCKET()
const;
119 virtual int CloseSocket();
120 virtual int ShutDownSocket(TShutMode shutMode = ShutModeNoRecvSend);
123 friend bool operator ==(
const TSocket& socket1,
const TSocket& socket2);
127 virtual void SetNotificationSet(
int notificationSet);
128 virtual void SetNotificationWindow(
TWindow* windowNotification);
129 virtual int CreateSocket();
136 virtual int BindSocket();
138 virtual void SetPeerSocketAddress(
TSocketAddress& newPeerSocketAddress);
139 virtual void SetSocketStyle(
int nNewFamily = PF_INET,
140 int nNewType = SOCK_STREAM,
141 int nNewProtocol = 0);
142 virtual int StartAcceptNotification();
143 virtual int StartRegularNotification();
144 virtual int StartCustomNotification(
int nSelectionOptions);
145 virtual int CancelNotification();
148 bool SetSaveSocketOnDelete(
bool saveSocket =
true);
150 virtual int ConvertProtocol(
char* protocol);
155 virtual ulong GetDriverWaitingSize();
156 virtual ulong GetTotalWaitingSize();
158 int& nAddressLength, SOCKET& socket);
160 int& nAddressLength);
162 int& nAddressLength, SOCKET& socket);
164 int& nAddressLength);
168 virtual void SetMaxReadBufferSize(
int nNewMaxReadBufferSize);
172 int SetBroadcastOption(
bool bBroadcast);
173 int SetDebugOption(
bool bDebug);
174 int SetLingerOption(
bool bLinger,
ushort nLingerTime=0);
175 int SetRouteOption(
bool bRoute);
176 int SetKeepAliveOption(
bool bKeepAlive);
177 int SetOOBOption(
bool bSendOOBDataInline);
178 int SetReceiveBufferOption(
int nReceiveBufferSize);
179 int SetSendBufferOption(
int nSendBufferSize);
180 int SetReuseAddressOption(
bool bAllowReuseAddress);
182 int GetBroadcastOption(
bool& bBroadcast);
183 int GetDebugOption(
bool& bDebug);
184 int GetLingerOption(
bool& bLinger,
ushort& nLingerTime);
185 int GetRouteOption(
bool& bRoute);
186 int GetKeepAliveOption(
bool& bKeepAlive);
187 int GetOOBOption(
bool& bSendOOBDataInline);
188 int GetReceiveBufferOption(
int& nReceiveBufferSize);
189 int GetSendBufferOption(
int& nSendBufferSize);
190 int GetReuseAddressOption(
bool& bAllowReuseAddress);
269 SocketParent = socket;
295TSocket::operator SOCKET()
const
The TSocketAddress class stores a Winsock socket address.
TSocket encapsulates the basic attributes of a socket.
virtual void SetNotificationSet(int notificationSet)
Assigns new set of notifications socket will catch.
int GetLastError()
Returns the last error of the socket.
virtual int DoCloseNotification(const SOCKET &s, int nError)
This isn't responded to in the generic TSocket class.
virtual int DoReadNotification(const SOCKET &s, int nError)
This function gets called whenever the socket gets a read notification.
bool SetSaveSocketOnDelete(bool saveSocket=true)
Saves the socket on deletion.
virtual int DoConnectNotification(const SOCKET &s, int nError)
This isn't responded to in the generic TSocket class.
friend class TSocketWindow
virtual int DoAcceptNotification(const SOCKET &s, int nError)
This isn't responded to in the generic TSocket class.
int Protocol
IPPROTO_TCP, etc.
short SaveSocket
Save the socket on deletion?
TSocketWindow Window
Will receive internal notifications and pass them to this class.
int Type
SOCK_STREAM, etc.
TSocket()
Default constructor for a socket.
int SocketsCallCheck(int error)
Checks the return error value from a sockets call, caching the last error if one occured (i....
virtual int DoWriteNotification(const SOCKET &s, int nError)
The generic socket doesn't know how many bytes it can send, since this limit is dependent on whether ...
void Init()
This function is an intitialization function called by the TSocket constructors.
int Family
PF_INET, etc. (this is the protocol family).
TShutMode
How to shutdown the socket.
@ ShutModeNoRecv
No more receives on the socket.
@ ShutModeNoSend
No more sends on the socket.
@ ShutModeNoRecvSend
No more sends or receives.
int MaxReadBufferSize
Maximum buffer size.
virtual void SetNotificationWindow(TWindow *windowNotification)
Sets the new notification window.
virtual int DoOOBNotification(const SOCKET &s, int nError)
This isn't responded to in the generic TSocket class.
void SetNotificationSet(int notificationSet)
Return the set of notifications socket will catch.
int StartRegularNotification()
This function turns on all Winsock notifications except FD_ACCEPT.
TWindow * WindowNotification
A second window that can be notified instead of the Socket.
TResult DoNotification(TParam1, TParam2)
DoNotification() is the SocketWindow's protected internal notification system.
int GetLastError()
Return the last error on the socket.
TSocket * GetSocketParent() const
DECLARE_RESPONSE_TABLE(TSocketWindow)
void SetSocketParent(TSocket *socket)
int StartAcceptNotification()
This function says to only listen to FD_ACCEPT messages.
int CancelNotification()
CancelNotification() turns off the notification to this window.
int NotificationSet
Types of notification to respond to.
int SelectOptions
We need to keep our own copy of this so we can do an assignment operator.
void SetNotificationWindow(TWindow *windowNotification)
Set the new notification window.
TSocketWindow(TSocket *socketParent)
int StartCustomNotification(int selectOptions)
The return value is WINSOCK_ERROR or WINSOCK_NOERROR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
TWindow(TWindow *parent, LPCTSTR title=nullptr, TModule *module=nullptr)
Adds this to the child list of parent if nonzero, and calls EnableAutoCreate so that this will be cre...
Object Windows Library (OWLNext Core).
TNotificationSet
Enumeration describing the type of event notifications you want to receive for a given socket.
@ NotifyRead
Notification of readiness for reading.
@ NotifyAccept
Notification of incoming connections.
@ NotifyOOB
Notification of the arrival of out-of-band data.
@ NotifyWrite
Notification of readiness for writing.
@ NotifyClose
Notification of socket closure.
@ NotifyAll
All notifications.
@ NotifyNone
No notifications.
@ NotifyConnect
Notification of completed connection.
LPARAM TParam2
Second parameter type.
WPARAM TParam1
First parameter type.
LRESULT TResult
Result type.
Base window class TWindow definition, including HWND encapsulation.
Winsock for OWL subsystem.