ReactOS  0.4.15-dev-4857-g47842d7
CSocket Class Reference

#include <socket.h>

Inheritance diagram for CSocket:
Collaboration diagram for CSocket:

Public Member Functions

 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 ()
 
virtual INT Transmit (LPCSTR lpsBuffer, UINT nLength)
 
virtual INT Receive (LPSTR lpsBuffer, UINT nLength)
 
virtual INT SendText (LPCSTR lpsStr)
 

Protected Attributes

SOCKET Socket
 
SOCKADDR_IN SockAddrIn
 
WSAEVENT Event
 
UINT Port
 
BOOL Active
 

Private Attributes

LONG Events
 

Detailed Description

Definition at line 72 of file socket.h.

Constructor & Destructor Documentation

◆ CSocket()

CSocket::CSocket ( )

Definition at line 18 of file socket.cpp.

19 {
20  Active = FALSE;
22  Events = 0;
24 
25  // INET address family
27 
28  // Any address will do
30 
31  // Convert to network ordering
33 }
u_short sin_port
Definition: winsock.h:511
SOCKADDR_IN SockAddrIn
Definition: socket.h:90
#define INADDR_ANY
Definition: StrAddr.c:4
#define WSA_INVALID_EVENT
Definition: winsock2.h:595
#define FALSE
Definition: types.h:117
LONG Events
Definition: socket.h:95
SOCKET Socket
Definition: socket.h:87
#define INVALID_SOCKET
Definition: winsock.h:332
struct in_addr sin_addr
Definition: winsock.h:512
#define htons(x)
Definition: module.h:213
#define AF_INET
Definition: tcpip.h:117
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:560
short sin_family
Definition: winsock.h:510

◆ ~CSocket()

CSocket::~CSocket ( )
virtual

Definition at line 36 of file socket.cpp.

37 {
38 }

Member Function Documentation

◆ Close()

VOID CSocket::Close ( void  )
virtual

Reimplemented in CServerSocket.

Definition at line 95 of file socket.cpp.

96 {
97 }

◆ GetEvents()

LONG CSocket::GetEvents ( )
virtual

Definition at line 84 of file socket.cpp.

85 {
86  return Events;
87 }
LONG Events
Definition: socket.h:95

◆ GetSockAddrIn()

SOCKADDR_IN CSocket::GetSockAddrIn ( )
virtual

Definition at line 54 of file socket.cpp.

55 {
56  return SockAddrIn;
57 }
SOCKADDR_IN SockAddrIn
Definition: socket.h:90

◆ GetSocket()

SOCKET CSocket::GetSocket ( )
virtual

Definition at line 41 of file socket.cpp.

42 {
43  return Socket;
44 }
SOCKET Socket
Definition: socket.h:87

◆ Open()

VOID CSocket::Open ( )
virtual

Reimplemented in CServerSocket.

Definition at line 90 of file socket.cpp.

91 {
92 }

◆ Receive()

virtual INT CSocket::Receive ( LPSTR  lpsBuffer,
UINT  nLength 
)
inlinevirtual

Reimplemented in CServerClientSocket.

Definition at line 86 of file socket.h.

86 { return 0; };

◆ SendText()

virtual INT CSocket::SendText ( LPCSTR  lpsStr)
inlinevirtual

Reimplemented in CServerClientSocket.

Definition at line 87 of file socket.h.

87 { return 0; };

◆ SetEvents()

VOID CSocket::SetEvents ( LONG  lEvents)
virtual

Definition at line 66 of file socket.cpp.

67 {
68  if (Event == WSA_INVALID_EVENT) {
69  // Create socket event
71  if (Event == WSA_INVALID_EVENT)
72  throw ESocketOpen(TS("Unable to create event."));
73  }
74 
75  if (lEvents != Events) {
76  // Associate network events with socket
77  if (WSAEventSelect(Socket, Event, lEvents) == SOCKET_ERROR)
78  throw ESocketOpen(TS("Unable to select socket events."));
79  Events = lEvents;
80  }
81 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define TS(x)
Definition: error.h:11
#define WSA_INVALID_EVENT
Definition: winsock2.h:595
LONG Events
Definition: socket.h:95
SOCKET Socket
Definition: socket.h:87
INT WSAAPI WSAEventSelect(IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
Definition: select.c:182
WSAEVENT WSAAPI WSACreateEvent(VOID)
Definition: event.c:42

Referenced by CServerSocket::MessageLoop(), and CServerSocket::Open().

◆ SetPort()

virtual VOID CSocket::SetPort ( UINT  nPort)
inlinevirtual

Reimplemented in CServerSocket.

Definition at line 82 of file socket.h.

82 {};

◆ SetSockAddrIn()

VOID CSocket::SetSockAddrIn ( SOCKADDR_IN  sockaddrin)
virtual

Definition at line 60 of file socket.cpp.

61 {
62  SockAddrIn = sockaddrin;
63 }
SOCKADDR_IN SockAddrIn
Definition: socket.h:90

Referenced by CServerSocket::MessageLoop().

◆ SetSocket()

VOID CSocket::SetSocket ( SOCKET  socket)
virtual

Definition at line 47 of file socket.cpp.

48 {
49  Socket = socket;
50 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
SOCKET Socket
Definition: socket.h:87

Referenced by CServerSocket::MessageLoop().

◆ Transmit()

virtual INT CSocket::Transmit ( LPCSTR  lpsBuffer,
UINT  nLength 
)
inlinevirtual

Reimplemented in CServerClientSocket.

Definition at line 85 of file socket.h.

85 { return 0; };

Member Data Documentation

◆ Active

BOOL CSocket::Active
protected

Definition at line 93 of file socket.h.

◆ Event

WSAEVENT CSocket::Event
protected

Definition at line 91 of file socket.h.

◆ Events

LONG CSocket::Events
private

Definition at line 95 of file socket.h.

Referenced by CSocket(), GetEvents(), and SetEvents().

◆ Port

UINT CSocket::Port
protected

Definition at line 92 of file socket.h.

Referenced by CServerSocket::Open(), and CServerSocket::SetPort().

◆ SockAddrIn

SOCKADDR_IN CSocket::SockAddrIn
protected

◆ Socket


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