In file socket.hxx:

class OStreamSocket : public OSocket, public IStream

A socket to send or receive a stream of data

Inheritance:


Public Methods

virtual Boolean isEof ()
Checks if socket is closed
OStreamSocket& operator= (oslSocket Socket)
Attaches the oslSocket to this object
OStreamSocket (oslSocket Socket)
Creates socket as wrapper around the underlying oslSocket
OStreamSocket (const OStreamSocket& Socket)
Copy constructor
OStreamSocket ()
Creates an unattached socket
virtual long read (void* pBuffer, long n)
Retrieves n bytes from the stream and copies them into pBuffer
int recv (void* pBuffer, int BytesToRead, TSocketMsgFlag Flag= msg_normal)
Tries to receives BytesToRead data from the connected socket,
int send (const void* pBuffer, int BytesToSend, TSocketMsgFlag Flag= msg_normal)
Tries to sends BytesToSend data from the connected socket
Boolean shutdown (TSocketDirection Direction= direction_readwrite)
Closes a connection in a controlled manner
virtual long write (const void* pBuffer, long n)
Writes n bytes from pBuffer to the stream
~OStreamSocket ()
Destructor

Protected Methods

OStreamSocket (TAddrFamily Family, TProtocol Protocol, TSocketType Type= sock_stream)
Creates a socket

Inherited from OSocket:

Public Methods

Boolean bind(const OSocketAddr& LocalInterface)
int clearError()
void close()
Boolean enableNonBlockingMode(Boolean On= True)
TSocketError getError()
void getError(char* pBuffer, int nSize)
void getLocalAddr(OSocketAddr& Addr)
const char* getLocalHost()
int getLocalPort()
int getOption(TSocketOption Option, void* pBuffer, int BufferLen, TSocketOptionLevel Level= sol_socket)
void getPeerAddr(OSocketAddr& Addr)
const char* getPeerHost()
int getPeerPort()
TSocketType getType()
Boolean isExceptionPending(int wp_sec, int wp_usec = 0)
Boolean isRecvReady(int wp_sec, int wp_usec = 0)
Boolean isSendReady(int wp_sec, int wp_usec = 0)
Boolean isValid()
operator oslSocket()
operator oslSocket()
int setBroadcast(int opt = -1)
int setDebug(int opt = -1)
int setDontRoute(int opt = -1)
int setKeepAlive(int opt = -1)
int setLinger(int time = -1)
int setOobinline(int opt = -1)
Boolean setOption(TSocketOption Option, void* pBuffer, int BufferLen, TSocketOptionLevel Level= sol_socket)
int setRecvBufSize(int size =-1)
int setRecvTimeout(int time= -1)
int setReuseAddr(int opt = -1)
int setSendBufSize(int size =-1)
int setSendTimeout(int time= -1)
int setTcpNoDelay(int sz =-1)

Inherited from ISocketTypes:


Inherited from IStream:


Documentation

A socket to send or receive a stream of data
OStreamSocket()
Creates an unattached socket. You must attach the socket to an oslSocket e.g. by using the operator=(oslSocket), before you can use the stream- functionality of the object.

OStreamSocket(oslSocket Socket)
Creates socket as wrapper around the underlying oslSocket
Parameters:
Socket -

OStreamSocket(const OStreamSocket& Socket)
Copy constructor
Parameters:
Socket -

~OStreamSocket()
Destructor. Calls shutdown(readwrite) and close().

OStreamSocket& operator=(oslSocket Socket)
Attaches the oslSocket to this object. If the object already was attached to an oslSocket, the old one will be closed and destroyed.
Parameters:
Socket. -

virtual long read(void* pBuffer, long n)
Retrieves n bytes from the stream and copies them into pBuffer. The method avoids incomplete reads due to packet boundaries.
Returns:
the number of read bytes. The number will only be smaller than n if an exceptional condition (e.g. connection closed) occurs.
Parameters:
pBuffer - receives the read data.
n - the number of bytes to read. pBuffer must be large enough to hold the n bytes!

virtual long write(const void* pBuffer, long n)
Writes n bytes from pBuffer to the stream. The method avoids incomplete writes due to packet boundaries.
Returns:
the number of written bytes. The number will only be smaller than n if an exceptional condition (e.g. connection closed) occurs.
Parameters:
pBuffer - contains the data to be written.
n - the number of bytes to write.

virtual Boolean isEof()
Checks if socket is closed
Returns:
True if socket is closed.

int recv(void* pBuffer, int BytesToRead, TSocketMsgFlag Flag= msg_normal)
Tries to receives BytesToRead data from the connected socket,
Returns:
the number of received bytes.
Parameters:
pBuffer - [out] Points to a buffer that will be filled with the received data.
BytesToRead - [in] The number of bytes to read. pBuffer must have at least this size.
Flag - [in] Modifier for the call. Valid values are:
  • msg_normal,
  • msg_oob,
  • msg_peek,
  • msg_dontroute,
  • msg_maxiovlen,

int send(const void* pBuffer, int BytesToSend, TSocketMsgFlag Flag= msg_normal)
Tries to sends BytesToSend data from the connected socket.
Returns:
the number of transfered bytes.
Parameters:
pBuffer - [in] Points to a buffer that contains the send-data.
BytesToSend - [in] The number of bytes to send. pBuffer must have at least this size.
Flag - [in] Modifier for the call. Valid values are:
  • msg_normal,
  • msg_oob,
  • msg_peek,
  • msg_dontroute,
  • msg_maxiovlen,

Boolean shutdown(TSocketDirection Direction= direction_readwrite)
Closes a connection in a controlled manner
Parameters:
Direction - Says which "end" of the socket is to be closed.

OStreamSocket(TAddrFamily Family, TProtocol Protocol, TSocketType Type= sock_stream)
Creates a socket. This constructor is used only by derived classes (e.g. OConnectorSocket).
Parameters:
Family -
Protocol -
Type - For some protocols it might be desirable to use a different type than sock_stream (like sock_seqpacket). Therefore we do not hide this parameter here.


Direct child classes:
OConnectorSocket

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de