OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TSocket Class Reference

TSocket encapsulates the basic attributes of a socket. More...

#include <owl/wsksock.h>

Inheritance diagram for owl::TSocket:
owl::TDatagramSocket owl::TStreamSocket

Public Types

enum  TShutMode { ShutModeNoRecv = 0 , ShutModeNoSend = 1 , ShutModeNoRecvSend = 2 }
 How to shutdown the socket. More...
 

Public Member Functions

 TSocket ()
 Default constructor for a socket.
 
 TSocket (SOCKET &newS)
 TSocket(SOCKET&) is a constructor based on a Winsock SOCKET descriptor.
 
 TSocket (TSocketAddress &newSocketAddress, int nNewFamily=PF_INET, int nNewType=SOCK_STREAM, int nNewProtocol=0)
 This is the standard constructor for a TSocket.
 
virtual ~TSocket ()
 This TSocket destructor will close the socket it if has not be closed already.
 
 operator SOCKET () const
 Returns the handle of the socket.
 
virtual int CloseSocket ()
 The CloseSocket() function is much like the Winsock closesocket() function.
 
virtual int ShutDownSocket (TShutMode shutMode=ShutModeNoRecvSend)
 The ShutDownSocket() function is much like the Winsock shutdown() function.
 
TSocketoperator= (TSocket &newSocket)
 
virtual void SetNotificationSet (int notificationSet)
 Assigns new set of notifications socket will catch.
 
virtual void SetNotificationWindow (TWindow *windowNotification)
 Sets the new notification window.
 
virtual int CreateSocket ()
 The CreateSocket function is much like the Winsock socket() function.
 
virtual int BindSocket (const TSocketAddress &addressToBindTo)
 binds to a given address
 
virtual int BindSocket ()
 binds to our address
 
virtual void SetMyAddress (TSocketAddress &newSocketAddress)
 This may be useful for changing the address or setting the address before binding.
 
virtual void SetPeerSocketAddress (TSocketAddress &newPeerSocketAddress)
 The 'myPeerSocketAddress' member variable is useful for Datagram sockets because it allows them to specify a default destination to send datagrams to.
 
virtual void SetSocketStyle (int nNewFamily=PF_INET, int nNewType=SOCK_STREAM, int nNewProtocol=0)
 The SetSocketStyle function can be used to set or change some TSocket member data.
 
virtual int StartAcceptNotification ()
 This function says to listen only to FD_ACCEPT messages.
 
virtual int StartRegularNotification ()
 This function turns on all Winsock notifications except FD_ACCEPT.
 
virtual int StartCustomNotification (int nSelectionOptions)
 The return value is WINSOCK_ERROR or WINSOCK_NOERROR.
 
virtual int CancelNotification ()
 CancelNotification() turns off the notification to this window.
 
bool SetSaveSocketOnDelete (bool saveSocket=true)
 Saves the socket on deletion.
 
virtual int ConvertProtocol (char *protocol)
 Converts a string protocol to integer value.
 
int GetLastError ()
 Returns the last error of the socket.
 
virtual ulong GetDriverWaitingSize ()
 GetDriverWaitingSize() is much like calling ioctlsocket(s, FIONREAD,...) in Winsock.
 
virtual ulong GetTotalWaitingSize ()
 Returns the total number of bytes waiting to be read.
 
virtual int GetMyAddress (TSocketAddress &socketAddress, int &nAddressLength, SOCKET &socket)
 This function stores the address into the reference argument 'socketAddress'.
 
virtual int GetMyAddress (TSocketAddress &socketAddress, int &nAddressLength)
 This function stores the address into the reference argument 'socketAddress'.
 
virtual int GetPeerAddress (TSocketAddress &socketAddress, int &nAddressLength, SOCKET &socket)
 The GetPeerAddress() function is much like the Winsock getpeername() function.
 
virtual int GetPeerAddress (TSocketAddress &socketAddress, int &nAddressLength)
 This version of GetPeerAddress() works on our own socket descriptor.
 
virtual void SetMaxReadBufferSize (int nNewMaxReadBufferSize)
 This should be called by someone who knows what the correct value is.
 
int SetBroadcastOption (bool bBroadcast)
 Allows transmission of broadcast messages.
 
int SetDebugOption (bool bDebug)
 Records debugging info.
 
int SetLingerOption (bool bLinger, ushort nLingerTime=0)
 If you set 'linger' to true, then that means to linger for 'lingerTime' seconds.
 
int SetRouteOption (bool bRoute)
 A false argument means don't route.
 
int SetKeepAliveOption (bool bKeepAlive)
 Sends keepAlive messages.
 
int SetOOBOption (bool bSendOOBDataInline)
 Receives out-of-band (OOB) data in the normal data stream.
 
int SetReceiveBufferOption (int nReceiveBufferSize)
 Sets the buffer size for receiving messages.
 
int SetSendBufferOption (int nSendBufferSize)
 Sets the buffer size for sending messages.
 
int SetReuseAddressOption (bool bAllowReuseAddress)
 Allows the socket to bind to an already-bound address.
 
int GetBroadcastOption (bool &bBroadcast)
 Retrieves the current broadcast option.
 
int GetDebugOption (bool &bDebug)
 Retrieves the current debugging option.
 
int GetLingerOption (bool &bLinger, ushort &nLingerTime)
 Retreives the current linger option.
 
int GetRouteOption (bool &bRoute)
 Retrieves the routing option.
 
int GetKeepAliveOption (bool &bKeepAlive)
 Retrieves the keepAlive option.
 
int GetOOBOption (bool &bSendOOBDataInline)
 Retrieves the out-of-band (OOB) option.
 
int GetReceiveBufferOption (int &nReceiveBufferSize)
 Retrieves the current receiving buffer size.
 
int GetSendBufferOption (int &nSendBufferSize)
 Retrieves the current sending buffer size.
 
int GetReuseAddressOption (bool &bAllowReuseAddress)
 Retrieves the reusable address option.
 

Protected Member Functions

void Init ()
 This function is an intitialization function called by the TSocket constructors.
 
int SocketsCallCheck (int error)
 Checks the return error value from a sockets call, caching the last error if one occured (i.e., error is non-zero).
 
virtual int DoReadNotification (const SOCKET &s, int nError)
 This function gets called whenever the socket gets a read notification.
 
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 the socket is a stream or datagram socket.
 
virtual int DoOOBNotification (const SOCKET &s, int nError)
 This isn't responded to in the generic TSocket class.
 
virtual int DoAcceptNotification (const SOCKET &s, int nError)
 This isn't responded to in the generic TSocket class.
 
virtual int DoConnectNotification (const SOCKET &s, int nError)
 This isn't responded to in the generic TSocket class.
 
virtual int DoCloseNotification (const SOCKET &s, int nError)
 This isn't responded to in the generic TSocket class.
 

Protected Attributes

int Family
 PF_INET, etc. (this is the protocol family)
 
int Type
 SOCK_STREAM, etc.
 
int Protocol
 IPPROTO_TCP, etc.
 
int LastError
 Last Error.
 
int MaxReadBufferSize
 Maximum buffer size.
 
short SaveSocket
 Save the socket on deletion?
 
TSocketWindow Window
 Will receive internal notifications and pass them to this class.
 

Friends

class TSocketWindow
 
bool operator== (const TSocket &socket1, const TSocket &socket2)
 While it's possible that two sockets could refer to the same SOCKET (though this would likely create a mess if not governed with care), it's defined as not possible that two Sockets could have the same window member.
 

Detailed Description

TSocket encapsulates the basic attributes of a socket.

A socket is an endpoint of communication to which a name may be bound. Each socket in use has a type and an associated process.

Definition at line 102 of file wsksock.h.

Member Enumeration Documentation

◆ TShutMode

How to shutdown the socket.

Enumerator
ShutModeNoRecv 

No more receives on the socket.

ShutModeNoSend 

No more sends on the socket.

ShutModeNoRecvSend 

No more sends or receives.

Definition at line 106 of file wsksock.h.

Constructor & Destructor Documentation

◆ TSocket() [1/3]

owl::TSocket::TSocket ( )

Default constructor for a socket.

The individual members of the TSocket can be set later.

Definition at line 21 of file wsksock.cpp.

References Init().

◆ TSocket() [2/3]

owl::TSocket::TSocket ( SOCKET & newS)

TSocket(SOCKET&) is a constructor based on a Winsock SOCKET descriptor.

Definition at line 39 of file wsksock.cpp.

References Family, GetMyAddress(), GetPeerAddress(), and Init().

◆ TSocket() [3/3]

owl::TSocket::TSocket ( TSocketAddress & newSocketAddress,
int newFamily = PF_INET,
int newType = SOCK_STREAM,
int newProtocol = 0 )

This is the standard constructor for a TSocket.

It doesn't call socket() or bind(). These must be done independently.

Definition at line 59 of file wsksock.cpp.

References Init().

◆ ~TSocket()

owl::TSocket::~TSocket ( )
virtual

This TSocket destructor will close the socket it if has not be closed already.

It will also delete the friend notification window.

Definition at line 79 of file wsksock.cpp.

References CloseSocket(), SaveSocket, and SetLingerOption().

Member Function Documentation

◆ BindSocket() [1/2]

int owl::TSocket::BindSocket ( )
virtual

binds to our address

This BindSocket simply binds with the previously defined member data socket address.

Definition at line 333 of file wsksock.cpp.

References BindSocket().

◆ BindSocket() [2/2]

int owl::TSocket::BindSocket ( const TSocketAddress & addressToBindTo)
virtual

binds to a given address

BindSocket is much like the Winsock bind() function.

Regardless of what mySocketAddress may have been previously, a call to 'bind()' immediately makes the socket's address the one put into the bind() call. Thus, mySocketAddress is always assigned to be boundSocketAddress. The address argument must be in network byte ordering. On the other hand, the SocketAddress class always keeps its addresses in network byte ordering.

Definition at line 315 of file wsksock.cpp.

References owl::TWinSockDll::bind(), LastError, WINSOCK_ERROR, WINSOCK_NOERROR, and owl::TWinSockDll::WSAGetLastError().

◆ CancelNotification()

int owl::TSocket::CancelNotification ( )
virtual

CancelNotification() turns off the notification to this window.

This also changes the socket to be blocking. The return value is WINSOCK_ERROR or WINSOCK_NOERROR. You can then examine GetLastError().

Definition at line 218 of file wsksock.cpp.

References owl::TSocketWindow::CancelNotification(), owl::TSocketWindow::GetLastError(), LastError, Window, and WINSOCK_ERROR.

◆ CloseSocket()

int owl::TSocket::CloseSocket ( )
virtual

The CloseSocket() function is much like the Winsock closesocket() function.

Definition at line 270 of file wsksock.cpp.

References owl::TWinSockDll::closesocket(), LastError, WINSOCK_ERROR, WINSOCK_NOERROR, and owl::TWinSockDll::WSAGetLastError().

◆ ConvertProtocol()

int owl::TSocket::ConvertProtocol ( char * protocol)
virtual

Converts a string protocol to integer value.

Makes assumptions about the protocol string. Only "tcp" and udp return valid values.

Definition at line 243 of file wsksock.cpp.

◆ CreateSocket()

int owl::TSocket::CreateSocket ( )
virtual

The CreateSocket function is much like the Winsock socket() function.

This function assumes that nFamily, nType, and nProtocol are already set properly. Note also that since the return of socket() is assigned to 's', that 's' must not already be used. This is another way of saying that there can only be one SOCKET for each TSocket object.

Definition at line 261 of file wsksock.cpp.

References Family, Protocol, owl::TWinSockDll::socket(), SocketsCallCheck(), and Type.

◆ DoAcceptNotification()

int owl::TSocket::DoAcceptNotification ( const SOCKET & s,
int nError )
protectedvirtual

This isn't responded to in the generic TSocket class.

Reimplemented in owl::TStreamSocket.

Definition at line 469 of file wsksock.cpp.

◆ DoCloseNotification()

int owl::TSocket::DoCloseNotification ( const SOCKET & s,
int nError )
protectedvirtual

This isn't responded to in the generic TSocket class.

Reimplemented in owl::TStreamSocket.

Definition at line 485 of file wsksock.cpp.

◆ DoConnectNotification()

int owl::TSocket::DoConnectNotification ( const SOCKET & s,
int nError )
protectedvirtual

This isn't responded to in the generic TSocket class.

Reimplemented in owl::TStreamSocket.

Definition at line 477 of file wsksock.cpp.

◆ DoOOBNotification()

int owl::TSocket::DoOOBNotification ( const SOCKET & s,
int nError )
protectedvirtual

This isn't responded to in the generic TSocket class.

Reimplemented in owl::TStreamSocket.

Definition at line 461 of file wsksock.cpp.

◆ DoReadNotification()

int owl::TSocket::DoReadNotification ( const SOCKET & s,
int nError )
protectedvirtual

This function gets called whenever the socket gets a read notification.

This means that data on the port is ready to be read. Thus this function must be subclassed by a DatagramSocket and StreamSocket.

Reimplemented in owl::TDatagramSocket, and owl::TStreamSocket.

Definition at line 443 of file wsksock.cpp.

◆ DoWriteNotification()

int owl::TSocket::DoWriteNotification ( const SOCKET & s,
int nError )
protectedvirtual

The generic socket doesn't know how many bytes it can send, since this limit is dependent on whether the socket is a stream or datagram socket.

Thus this function must be subclassed by a DatagramSocket and StreamSocket.

Reimplemented in owl::TDatagramSocket, and owl::TStreamSocket.

Definition at line 453 of file wsksock.cpp.

◆ GetBroadcastOption()

int owl::TSocket::GetBroadcastOption ( bool & bBroadcast)

Retrieves the current broadcast option.

Definition at line 596 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetDebugOption()

int owl::TSocket::GetDebugOption ( bool & bDebug)

Retrieves the current debugging option.

Definition at line 608 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetDriverWaitingSize()

ulong owl::TSocket::GetDriverWaitingSize ( )
virtual

GetDriverWaitingSize() is much like calling ioctlsocket(s, FIONREAD,...) in Winsock.

It returns the number of bytes waiting to be read on the socket. For datagrams, it is the size of the next datagram. For streams, it should be the total waiting bytes.

Definition at line 418 of file wsksock.cpp.

References owl::TWinSockDll::ioctlsocket().

◆ GetKeepAliveOption()

int owl::TSocket::GetKeepAliveOption ( bool & bKeepAlive)

Retrieves the keepAlive option.

Definition at line 653 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetLastError()

int owl::TSocket::GetLastError ( )
inline

Returns the last error of the socket.

Definition at line 313 of file wsksock.h.

References LastError.

◆ GetLingerOption()

int owl::TSocket::GetLingerOption ( bool & bLinger,
ushort & nLingerTime )

Retreives the current linger option.

Definition at line 620 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), SocketsCallCheck(), WINSOCK_ERROR, and WINSOCK_NOERROR.

◆ GetMyAddress() [1/2]

int owl::TSocket::GetMyAddress ( TSocketAddress & socketAddress,
int & addressLength )
virtual

This function stores the address into the reference argument 'socketAddress'.

'addressLength' will hold the length of the address. Uses the SOCKET in my member data as the socket to get the address of.

Definition at line 353 of file wsksock.cpp.

References GetMyAddress().

◆ GetMyAddress() [2/2]

int owl::TSocket::GetMyAddress ( TSocketAddress & socketAddress,
int & addressLength,
SOCKET & socket )
virtual

This function stores the address into the reference argument 'socketAddress'.

'addressLength' will hold the length of the address. 'socket' refers to the socket whose address will be examined.

Definition at line 343 of file wsksock.cpp.

References owl::TWinSockDll::getsockname(), and SocketsCallCheck().

◆ GetOOBOption()

int owl::TSocket::GetOOBOption ( bool & bSendOOBDataInline)

Retrieves the out-of-band (OOB) option.

Definition at line 665 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetPeerAddress() [1/2]

int owl::TSocket::GetPeerAddress ( TSocketAddress & socketAddress,
int & nAddressLength )
virtual

This version of GetPeerAddress() works on our own socket descriptor.

Definition at line 379 of file wsksock.cpp.

References GetPeerAddress().

◆ GetPeerAddress() [2/2]

int owl::TSocket::GetPeerAddress ( TSocketAddress & socketAddress,
int & addressLength,
SOCKET & socket )
virtual

The GetPeerAddress() function is much like the Winsock getpeername() function.

The Winsock getpeername() function is misnamed; it should be getpeeraddress(). socketAddress will be changed to have the right addressing info, and nAddressLength will be set to be the address length. Note that this function can be used to get the address for any socket descriptor, not just our own socket descriptor.

Definition at line 366 of file wsksock.cpp.

References owl::TWinSockDll::getpeername(), and SocketsCallCheck().

◆ GetReceiveBufferOption()

int owl::TSocket::GetReceiveBufferOption ( int & nReceiveBufferSize)

Retrieves the current receiving buffer size.

Definition at line 677 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetReuseAddressOption()

int owl::TSocket::GetReuseAddressOption ( bool & bAllowReuseAddress)

Retrieves the reusable address option.

Definition at line 695 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetRouteOption()

int owl::TSocket::GetRouteOption ( bool & bRoute)

Retrieves the routing option.

Definition at line 636 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), SocketsCallCheck(), WINSOCK_ERROR, and WINSOCK_NOERROR.

◆ GetSendBufferOption()

int owl::TSocket::GetSendBufferOption ( int & nSendBufferSize)

Retrieves the current sending buffer size.

Definition at line 686 of file wsksock.cpp.

References owl::TWinSockDll::getsockopt(), and SocketsCallCheck().

◆ GetTotalWaitingSize()

ulong owl::TSocket::GetTotalWaitingSize ( )
virtual

Returns the total number of bytes waiting to be read.

Definition at line 433 of file wsksock.cpp.

References GetDriverWaitingSize().

◆ Init()

void owl::TSocket::Init ( )
protected

This function is an intitialization function called by the TSocket constructors.

It simply creates the friend window that the TSocket needs for Winsock notifications.

Definition at line 92 of file wsksock.cpp.

References owl::TWindow::Create(), and Window.

◆ operator SOCKET()

owl::TSocket::operator SOCKET ( ) const
inline

Returns the handle of the socket.

Definition at line 295 of file wsksock.h.

◆ operator=()

TSocket & owl::TSocket::operator= ( TSocket & newSocket)

◆ SetBroadcastOption()

int owl::TSocket::SetBroadcastOption ( bool bBroadcast)

Allows transmission of broadcast messages.

Definition at line 502 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetDebugOption()

int owl::TSocket::SetDebugOption ( bool bDebug)

Records debugging info.

Definition at line 513 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetKeepAliveOption()

int owl::TSocket::SetKeepAliveOption ( bool bKeepAlive)

Sends keepAlive messages.

Definition at line 553 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetLingerOption()

int owl::TSocket::SetLingerOption ( bool linger,
ushort lingerTime = 0 )

If you set 'linger' to true, then that means to linger for 'lingerTime' seconds.

Examples:

  • linger=true, lingerTime=0 Hard immediate close. All queued data for sending gets canned immediately.
  • linger=true, lingerTime=2. Graceful close. Waits 2 seconds to try to send any pending data.
  • linger=false, lingerTime=<any>. "Graceful" immediate close. Causes data to be still in queue to send when ready.

Definition at line 531 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetMaxReadBufferSize()

void owl::TSocket::SetMaxReadBufferSize ( int nNewMaxReadBufferSize)
virtual

This should be called by someone who knows what the correct value is.

Definition at line 493 of file wsksock.cpp.

References MaxReadBufferSize.

◆ SetMyAddress()

void owl::TSocket::SetMyAddress ( TSocketAddress & newSocketAddress)
virtual

This may be useful for changing the address or setting the address before binding.

It's no good to change this after binding, as a binding is a permanent association between a socket descriptor and a full address (for IP, this is a ushort port and ulong address).

Definition at line 390 of file wsksock.cpp.

◆ SetNotificationSet()

void owl::TSocket::SetNotificationSet ( int notificationSet)
inlinevirtual

Assigns new set of notifications socket will catch.

Definition at line 277 of file wsksock.h.

References owl::TSocketWindow::SetNotificationSet(), and Window.

◆ SetNotificationWindow()

void owl::TSocket::SetNotificationWindow ( TWindow * windowNotification)
inlinevirtual

Sets the new notification window.

Definition at line 286 of file wsksock.h.

References owl::TSocketWindow::SetNotificationWindow(), and Window.

◆ SetOOBOption()

int owl::TSocket::SetOOBOption ( bool bSendOOBDataInline)

Receives out-of-band (OOB) data in the normal data stream.

Definition at line 562 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetPeerSocketAddress()

void owl::TSocket::SetPeerSocketAddress ( TSocketAddress & newPeerSocketAddress)
virtual

The 'myPeerSocketAddress' member variable is useful for Datagram sockets because it allows them to specify a default destination to send datagrams to.

With a default destination, a datagram socket that always or often sends to one address can simply call the Write or Send functions with no address arguments and the data will send to the default address. This function can also be used by a stream socket to set the address for a peer that it wants to connect to.

Definition at line 403 of file wsksock.cpp.

◆ SetReceiveBufferOption()

int owl::TSocket::SetReceiveBufferOption ( int nReceiveBufferSize)

Sets the buffer size for receiving messages.

Definition at line 571 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetReuseAddressOption()

int owl::TSocket::SetReuseAddressOption ( bool bAllowReuseAddress)

Allows the socket to bind to an already-bound address.

Definition at line 587 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetRouteOption()

int owl::TSocket::SetRouteOption ( bool bRoute)

A false argument means don't route.

Definition at line 544 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetSaveSocketOnDelete()

bool owl::TSocket::SetSaveSocketOnDelete ( bool saveSocket = true)
inline

Saves the socket on deletion.

Definition at line 304 of file wsksock.h.

References SaveSocket.

◆ SetSendBufferOption()

int owl::TSocket::SetSendBufferOption ( int nSendBufferSize)

Sets the buffer size for sending messages.

Definition at line 579 of file wsksock.cpp.

References owl::TWinSockDll::setsockopt(), and SocketsCallCheck().

◆ SetSocketStyle()

void owl::TSocket::SetSocketStyle ( int newFamily = PF_INET,
int newType = SOCK_STREAM,
int newProtocol = 0 )
virtual

The SetSocketStyle function can be used to set or change some TSocket member data.

Note that the newFamily is also represented in the TSocketAddress member, and so they should match.

Definition at line 232 of file wsksock.cpp.

References Family, Protocol, and Type.

◆ ShutDownSocket()

int owl::TSocket::ShutDownSocket ( TShutMode shutMode = ShutModeNoRecvSend)
virtual

The ShutDownSocket() function is much like the Winsock shutdown() function.

Note that shutting down a socket essentially means that you can't un-shut it down. It's a graceful way of preparing to end a session, somewhat like a yellow stoplight. Use this function to close your socket, while still allowing data be received from the network. This is as opposed to CloseSocket(), which kills all transfers in both directions. shutMode is one of the enumerations: ShutModeNoRecv, ShutModeNoSend, or ShutModeNoRecvSend.

Definition at line 293 of file wsksock.cpp.

References LastError, owl::TWinSockDll::shutdown(), WINSOCK_ERROR, WINSOCK_NOERROR, and owl::TWinSockDll::WSAGetLastError().

◆ SocketsCallCheck()

int owl::TSocket::SocketsCallCheck ( int error)
protected

Checks the return error value from a sockets call, caching the last error if one occured (i.e., error is non-zero).

Returns a Winsock error/noerror code.

Definition at line 108 of file wsksock.cpp.

References LastError, WINSOCK_ERROR, WINSOCK_NOERROR, and owl::TWinSockDll::WSAGetLastError().

◆ StartAcceptNotification()

int owl::TSocket::StartAcceptNotification ( )
virtual

This function says to listen only to FD_ACCEPT messages.

Note that a socket set up to be a listening socket will never be a connected socket, and a connected socket will never receive FD_ACCEPT messages. Thus all stream sockets are implicitly either connected sockets or listening sockets. Since the accepted socket needs a different notification window from the listening socket, and the sockets specification says that an accepted socket inherits the notification properties of the listening socket, the listening socket must not be set to receive FD_READ, etc, notifications. This is because it's possible that between the accept() call for the new socket and the WSAAsyncSelect() call for the new socket, data may be received for the new socket. Thus the listening socket may get sent the message and it would never get routed to the new socket. Calling this function is saying that this SocketWindow is for listening for connections.

The return value is WINSOCK_ERROR or WINSOCK_NOERROR. You can then examine GetLastError().

Definition at line 171 of file wsksock.cpp.

References owl::TSocketWindow::GetLastError(), LastError, owl::TSocketWindow::StartAcceptNotification(), Window, and WINSOCK_ERROR.

◆ StartCustomNotification()

int owl::TSocket::StartCustomNotification ( int selectionOptions)
virtual

The return value is WINSOCK_ERROR or WINSOCK_NOERROR.

You can then examine GetLastError().

Definition at line 203 of file wsksock.cpp.

References owl::TSocketWindow::GetLastError(), LastError, owl::TSocketWindow::StartCustomNotification(), Window, and WINSOCK_ERROR.

◆ StartRegularNotification()

int owl::TSocket::StartRegularNotification ( )
virtual

This function turns on all Winsock notifications except FD_ACCEPT.

Calling this function is saying that this SocketWindow is for connections rather than for listening. Since a Winsock socket cannot be a listening socket and a connected socket at the same time, the notification functions are separated from each other: StartAcceptNotification() and StartRegularNotification().

The return value is WINSOCK_ERROR or WINSOCK_NOERROR. You can then examine GetLastError().

Definition at line 190 of file wsksock.cpp.

References owl::TSocketWindow::GetLastError(), LastError, owl::TSocketWindow::StartRegularNotification(), Window, and WINSOCK_ERROR.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const TSocket & socket1,
const TSocket & socket2 )
friend

While it's possible that two sockets could refer to the same SOCKET (though this would likely create a mess if not governed with care), it's defined as not possible that two Sockets could have the same window member.

This is because the window is created uniquely on construction for each TSocket.

Definition at line 149 of file wsksock.cpp.

◆ TSocketWindow

Definition at line 210 of file wsksock.h.

Member Data Documentation

◆ Family

int owl::TSocket::Family
protected

PF_INET, etc. (this is the protocol family)

Definition at line 203 of file wsksock.h.

◆ LastError

int owl::TSocket::LastError
protected

Last Error.

Definition at line 206 of file wsksock.h.

◆ MaxReadBufferSize

int owl::TSocket::MaxReadBufferSize
protected

Maximum buffer size.

Definition at line 207 of file wsksock.h.

◆ Protocol

int owl::TSocket::Protocol
protected

IPPROTO_TCP, etc.

Definition at line 205 of file wsksock.h.

◆ SaveSocket

short owl::TSocket::SaveSocket
protected

Save the socket on deletion?

Definition at line 208 of file wsksock.h.

◆ Type

int owl::TSocket::Type
protected

SOCK_STREAM, etc.

Definition at line 204 of file wsksock.h.

◆ Window

TSocketWindow owl::TSocket::Window
protected

Will receive internal notifications and pass them to this class.

Definition at line 209 of file wsksock.h.


The documentation for this class was generated from the following files: