Ginga  0.13.6
 All Classes Namespaces Functions Variables
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
br::pucrio::telemidia::ginga::core::system::compat::Socket Class Reference

#include <PracticalSocket.h>

Inheritance diagram for br::pucrio::telemidia::ginga::core::system::compat::Socket:
Inheritance graph
[legend]

Public Member Functions

 ~Socket ()
 
string getLocalAddress () throw (SocketException)
 
unsigned short getLocalPort () throw (SocketException)
 
void setLocalPort (unsigned short localPort) throw (SocketException)
 
void setLocalAddressAndPort (const string &localAddress, unsigned short localPort=0) throw (SocketException)
 

Static Public Member Functions

static void cleanUp () throw (SocketException)
 
static unsigned short resolveService (const string &service, const string &protocol="tcp")
 

Protected Member Functions

 Socket (int type, int protocol) throw (SocketException)
 
 Socket (int sockDesc)
 

Protected Attributes

int sockDesc
 

Detailed Description

Base class representing basic communication endpoint

Constructor & Destructor Documentation

br::pucrio::telemidia::ginga::core::system::compat::Socket::~Socket ( )

Close and deallocate this socket

Member Function Documentation

void br::pucrio::telemidia::ginga::core::system::compat::Socket::cleanUp ( )
throw (SocketException
)
static

If WinSock, unload the WinSock DLLs; otherwise do nothing. We ignore this in our sample client code but include it in the library for completeness. If you are running on Windows and you are concerned about DLL resource consumption, call this after you are done with all Socket instances. If you execute this on Windows while some instance of Socket exists, you are toast. For portability of client code, this is an empty function on non-Windows platforms so you can always include it.

Parameters
bufferbuffer to receive the data
bufferLenmaximum number of bytes to read into buffer
Returns
number of bytes read, 0 for EOF, and -1 for error
Exceptions
SocketExceptionthrown WinSock clean up fails
string br::pucrio::telemidia::ginga::core::system::compat::Socket::getLocalAddress ( )
throw (SocketException
)

Get the local address

Returns
local address of socket
Exceptions
SocketExceptionthrown if fetch fails
unsigned short br::pucrio::telemidia::ginga::core::system::compat::Socket::getLocalPort ( )
throw (SocketException
)

Get the local port

Returns
local port of socket
Exceptions
SocketExceptionthrown if fetch fails
unsigned short br::pucrio::telemidia::ginga::core::system::compat::Socket::resolveService ( const string &  service,
const string &  protocol = "tcp" 
)
static

Resolve the specified service for the specified protocol to the corresponding port number in host byte order

Parameters
serviceservice to resolve (e.g., "http")
protocolprotocol of service to resolve. Default is "tcp".
void br::pucrio::telemidia::ginga::core::system::compat::Socket::setLocalAddressAndPort ( const string &  localAddress,
unsigned short  localPort = 0 
)
throw (SocketException
)

Set the local port to the specified port and the local address to the specified address. If you omit the port, a random port will be selected.

Parameters
localAddresslocal address
localPortlocal port
Exceptions
SocketExceptionthrown if setting local port or address fails
void br::pucrio::telemidia::ginga::core::system::compat::Socket::setLocalPort ( unsigned short  localPort)
throw (SocketException
)

Set the local port to the specified port and the local address to any interface

Parameters
localPortlocal port
Exceptions
SocketExceptionthrown if setting local port fails

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