ReactOS  0.4.15-dev-4570-g4f8bbd1
CServerClientSocket Class Reference

#include <socket.h>

Inheritance diagram for CServerClientSocket:
Collaboration diagram for CServerClientSocket:

Public Member Functions

 CServerClientSocket ()
 
 CServerClientSocket (LPCServerSocket lpServerSocket)
 
CServerSocketGetServerSocket ()
 
virtual INT Transmit (LPCSTR lpsBuffer, UINT nLength)
 
virtual INT Receive (LPSTR lpsBuffer, UINT nLength)
 
virtual INT SendText (LPCSTR lpsText)
 
virtual VOID MessageLoop ()
 
virtual VOID OnRead ()
 
virtual VOID OnClose ()
 
- Public Member Functions inherited from CSocket
 CSocket ()
 
virtual ~CSocket ()
 
virtual SOCKET GetSocket ()
 
virtual VOID SetSocket (SOCKET socket)
 
virtual SOCKADDR_IN GetSockAddrIn ()
 
virtual VOID SetSockAddrIn (SOCKADDR_IN sockaddrin)
 
virtual VOID SetEvents (LONG lEvents)
 
virtual LONG GetEvents ()
 
virtual VOID SetPort (UINT nPort)
 
virtual VOID Open ()
 
virtual VOID Close ()
 

Protected Attributes

LPCServerSocket ServerSocket
 
- Protected Attributes inherited from CSocket
SOCKET Socket
 
SOCKADDR_IN SockAddrIn
 
WSAEVENT Event
 
UINT Port
 
BOOL Active
 

Detailed Description

Definition at line 98 of file socket.h.

Constructor & Destructor Documentation

◆ CServerClientSocket() [1/2]

CServerClientSocket::CServerClientSocket ( )
inline

Definition at line 100 of file socket.h.

100 {};

◆ CServerClientSocket() [2/2]

CServerClientSocket::CServerClientSocket ( LPCServerSocket  lpServerSocket)

Definition at line 103 of file socket.cpp.

104 {
105  ServerSocket = lpServerSocket;
106 }
LPCServerSocket ServerSocket
Definition: socket.h:109

Member Function Documentation

◆ GetServerSocket()

LPCServerSocket CServerClientSocket::GetServerSocket ( )

Definition at line 149 of file socket.cpp.

150 {
151  return ServerSocket;
152 }
LPCServerSocket ServerSocket
Definition: socket.h:109

Referenced by CServerClientThread::~CServerClientThread().

◆ MessageLoop()

VOID CServerClientSocket::MessageLoop ( )
virtual

Definition at line 132 of file socket.cpp.

133 {
134  UINT nStatus;
135  WSANETWORKEVENTS NetworkEvents;
136 
137  nStatus = WSAWaitForMultipleEvents(1, &Event, FALSE, 0, FALSE);
138  if ((nStatus == 0) && (WSAEnumNetworkEvents(Socket, Event, &NetworkEvents) != SOCKET_ERROR)) {
139  if ((NetworkEvents.lNetworkEvents & FD_READ) != 0) {
140  OnRead();
141  }
142  if ((NetworkEvents.lNetworkEvents & FD_CLOSE) != 0) {
143  OnClose();
144  }
145  }
146 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define FD_READ
Definition: winsock.h:405
DWORD WSAAPI WSAWaitForMultipleEvents(IN DWORD cEvents, IN CONST WSAEVENT FAR *lphEvents, IN BOOL fWaitAll, IN DWORD dwTimeout, IN BOOL fAlertable)
Definition: event.c:75
#define FALSE
Definition: types.h:117
SOCKET Socket
Definition: socket.h:87
virtual VOID OnClose()
Definition: socket.h:109
#define FD_CLOSE
Definition: winsock.h:410
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
unsigned int UINT
Definition: ndis.h:50
virtual VOID OnRead()
Definition: socket.h:107

◆ OnClose()

virtual VOID CServerClientSocket::OnClose ( )
inlinevirtual

Reimplemented in CHttpClient.

Definition at line 109 of file socket.h.

109 {};

Referenced by MessageLoop().

◆ OnRead()

virtual VOID CServerClientSocket::OnRead ( )
inlinevirtual

Reimplemented in CHttpClient.

Definition at line 107 of file socket.h.

107 {};

Referenced by MessageLoop().

◆ Receive()

INT CServerClientSocket::Receive ( LPSTR  lpsBuffer,
UINT  nLength 
)
virtual

Reimplemented from CSocket.

Definition at line 126 of file socket.cpp.

127 {
128  return recv(Socket, lpsBuffer, nLength, 0);
129 }
_In_ DWORD nLength
Definition: wincon.h:473
SOCKET Socket
Definition: socket.h:87
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23

◆ SendText()

INT CServerClientSocket::SendText ( LPCSTR  lpsText)
virtual

Reimplemented from CSocket.

Definition at line 115 of file socket.cpp.

116 {
117  static CHAR crlf[3] = {0x0D, 0x0A, 0x00};
118  INT nCount;
119 
120  nCount = Transmit(lpsText, strlen(lpsText));
121  nCount += Transmit(crlf, strlen(crlf));
122  return nCount;
123 }
virtual INT Transmit(LPCSTR lpsBuffer, UINT nLength)
Definition: socket.cpp:109
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:58
static const WCHAR crlf[]
Definition: object.c:1018

◆ Transmit()

INT CServerClientSocket::Transmit ( LPCSTR  lpsBuffer,
UINT  nLength 
)
virtual

Reimplemented from CSocket.

Definition at line 109 of file socket.cpp.

110 {
111  return send(Socket, lpsBuffer, nLength, 0);
112 }
_In_ DWORD nLength
Definition: wincon.h:473
SOCKET Socket
Definition: socket.h:87
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23

Referenced by SendText().

Member Data Documentation

◆ ServerSocket

LPCServerSocket CServerClientSocket::ServerSocket
protected

Definition at line 109 of file socket.h.

Referenced by CServerClientSocket(), and GetServerSocket().


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