NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Embed: (wiki syntax)

« Back to documentation index

TCPSocket Class Reference

TCPSocket Class Reference

This is a simple TCP Socket class. More...

#include <TCPSocket.h>

Public Member Functions

 TCPSocket ()
 Creates a new socket.
 ~TCPSocket ()
 Closes if needed and destroys the socket.
TCPSocketErr bind (const Host &me)
 Binds the socket to (local) host.
TCPSocketErr listen ()
 Starts listening.
TCPSocketErr connect (const Host &host)
 Connects socket to host.
TCPSocketErr accept (Host *pClient, TCPSocket **ppNewTcpSocket)
 Accepts connection from client and gets connected socket.
int send (const char *buf, int len)
 Sends data.
int recv (char *buf, int len)
 Receives data.
TCPSocketErr close ()
 Closes socket.
void setOnEvent (void(*pMethod)(TCPSocketEvent))
 Setups callback.
template<class T >
void setOnEvent (T *pItem, void(T::*pMethod)(TCPSocketEvent))
 Setups callback.
void resetOnEvent ()
 Disables callback.

Detailed Description

This is a simple TCP Socket class.

This class exposes an API to deal with TCP Sockets

Definition at line 71 of file TCPSocket.h.


Constructor & Destructor Documentation

TCPSocket (  )

Creates a new socket.

Definition at line 27 of file TCPSocket.cpp.

~TCPSocket (  )

Closes if needed and destroys the socket.

Definition at line 37 of file TCPSocket.cpp.


Member Function Documentation

TCPSocketErr accept ( Host pClient,
TCPSocket **  ppNewTcpSocket 
)

Accepts connection from client and gets connected socket.

Definition at line 66 of file TCPSocket.cpp.

TCPSocketErr bind ( const Host me )

Binds the socket to (local) host.

Definition at line 42 of file TCPSocket.cpp.

TCPSocketErr close (  )

Closes socket.

Definition at line 94 of file TCPSocket.cpp.

TCPSocketErr connect ( const Host host )

Connects socket to host.

Definition at line 58 of file TCPSocket.cpp.

TCPSocketErr listen (  )

Starts listening.

Definition at line 50 of file TCPSocket.cpp.

int recv ( char *  buf,
int  len 
)

Receives data.

Definition at line 86 of file TCPSocket.cpp.

void resetOnEvent (  )

Disables callback.

Definition at line 120 of file TCPSocket.cpp.

int send ( const char *  buf,
int  len 
)

Sends data.

Definition at line 78 of file TCPSocket.cpp.

void setOnEvent ( void(*)(TCPSocketEvent pMethod )

Setups callback.

Parameters:
pMethod: callback function

Definition at line 106 of file TCPSocket.cpp.

void setOnEvent ( T *  pItem,
void(T::*)(TCPSocketEvent pMethod 
)

Setups callback.

Parameters:
pItem: instance of class on which to execute the callback method
pMethod: callback method

Definition at line 125 of file TCPSocket.h.