Main Page | Class Hierarchy | Class List | File List | Class Members

Socket Class Reference

Representation of a Socket and many of the Berkeley functions available.

#include <sstuff.hh>

List of all members.

Public Member Functions

 Socket (AddressFamily af, SocketType st, ProtocolType pt=0)
 Construct a socket of specified AddressFamily and SocketType.

Socketaccept ()
 If the socket is capable of doing so, this function will wait for a connection.

void setNonBlocking ()
 Set the socket to non-blocking.

void bind (const IPEndpoint &ep)
 Bind the socket to a specified endpoint.

void recvFrom (string &dgram, IPEndpoint &ep)
 For datagram sockets, receive a datagram and learn where it came from.

void sendTo (const string &dgram, const IPEndpoint &ep)
 For datagram sockets, send a datagram to a destination.

void writen (const string &data)
 Write this data to the socket, taking care that all bytes are written out.

unsigned int tryWrite (const char *ptr, int toWrite)
 tries to write toWrite bytes from ptr to the socket

unsigned int write (const char *ptr, int toWrite)
 Writes toWrite bytes from ptr to the socket.

int getchar ()
 reads one character from the socket

void read (string &data)
 Reads a block of data from the socket to a string.

int read (char *buffer, int bytes)
 Reads a block of data from the socket to a block of memory.

void listen (unsigned int length=10)
 Sets the socket to listen with a default listen backlog of 10 bytes.

int getHandle () const
 Returns the internal file descriptor of the socket.


Member Function Documentation

void Socket::recvFrom string &  dgram,
IPEndpoint ep
[inline]
 

For datagram sockets, receive a datagram and learn where it came from

Parameters:
dgram Will be filled with the datagram
ep Will be filled with the origin of the datagram

Definition at line 144 of file sstuff.hh.

References IPEndpoint::address, IPAddress::byte, and IPEndpoint::port.

Referenced by UDPListener::recvFrom().

void Socket::sendTo const string &  dgram,
const IPEndpoint ep
[inline]
 

For datagram sockets, send a datagram to a destination

Parameters:
dgram The datagram
ep The intended destination of the datagram

Definition at line 161 of file sstuff.hh.

References IPEndpoint::address, IPAddress::byte, and IPEndpoint::port.

Referenced by UDPListener::sendTo().

unsigned int Socket::tryWrite const char *  ptr,
int  toWrite
[inline]
 

tries to write toWrite bytes from ptr to the socket, but does not make sure they al get written out

Parameters:
ptr Location to write from
toWrite number of bytes to try

Definition at line 191 of file sstuff.hh.

unsigned int Socket::write const char *  ptr,
int  toWrite
[inline]
 

Writes toWrite bytes from ptr to the socket. Returns how many bytes were written

Definition at line 209 of file sstuff.hh.


The documentation for this class was generated from the following file:
Generated on Sun Feb 8 12:07:52 2004 for MTasker by doxygen 1.3.5