WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
WXP::Socket Class Reference

This class manages socket based network connections. More...

#include "../include/Socket.h"

Public Types

enum  Type {
  UNK , DGRAM , DGRAM_SERVER , DGRAM_CLIENT ,
  STREAM , STREAM_SERVER , STREAM_CLIENT
}
 

Public Member Functions

 Socket ()
 
 ~Socket ()
 
int init ()
 
bool isOpen ()
 
int open (const char *address, int type)
 
int close ()
 
int reconnect ()
 
int read (unsigned char *buf, int size)
 
int readLine (unsigned char *buf, int size)
 
int write (const unsigned char *buf, int size)
 

Detailed Description

This class manages socket based network connections.

Author
Dan Vietor

Constructor & Destructor Documentation

◆ Socket()

Socket::Socket ( )

Constructor - initializes data

References init().

◆ ~Socket()

Socket::~Socket ( )

Destructor - cleans up socket connection

References close().

Member Function Documentation

◆ close()

int Socket::close ( )

Closes and cleans up socket connection

References close().

Referenced by close(), and ~Socket().

◆ init()

int Socket::init ( )

Initializes data

Referenced by Socket().

◆ open()

int Socket::open ( const char *  address,
int  rtype 
)

Opens the socket

Parameters
addressThe host:port
rtypeType of socket (DGRAM_SERVER, DGRAM_CLIENT, STREAM_SERVER, STREAM_CLIENT)
Returns
1=success

References WXP::Wxp::outWarning(), and WXP::Wxp::sleep().

◆ read()

int Socket::read ( unsigned char *  buf,
int  size 
)

Reads data from socket

Parameters
bufThe buffer to write data to
sizeThe size of the buffer
Returns
The number of bytes read

Referenced by readLine().

◆ readLine()

int Socket::readLine ( unsigned char *  buf,
int  bsize 
)

Reads a line (terminated with
) of data from socket

Parameters
bufThe buffer to write data to
bsizeThe size of the buffer
Returns
The number of bytes read

References read().


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