Yate
Public Member Functions | Friends

JBSocket Class Reference

A Jabber streams's socket. More...

#include <yatejabber.h>

List of all members.

Public Member Functions

 JBSocket (JBEngine *engine, JBStream *stream, const char *address, int port)
 ~JBSocket ()
bool valid () const
const SocketAddraddr () const
const Stringerror () const
bool connect (bool &terminated, const char *newAddr, int newPort=0)
void terminate (bool shutdown=false)
bool recv (char *buffer, unsigned int &len)
bool send (const char *buffer, unsigned int &len)

Friends

class JBStream

Detailed Description

A Jabber streams's socket.

A socket used used to transport data for a Jabber stream


Constructor & Destructor Documentation

JBSocket ( JBEngine engine,
JBStream stream,
const char *  address,
int  port 
)

Constructor. Build socket for an outgoing stream

Parameters:
engineThe Jabber engine
streamThe stream owning this socket
addressThe address used to connect to
portPort used to connect to remote server
~JBSocket ( ) [inline]

Destructor. Close the socket


Member Function Documentation

const SocketAddr& addr ( ) const [inline]

Get the remote peer's address

Returns:
The remote peer's address
bool connect ( bool &  terminated,
const char *  newAddr,
int  newPort = 0 
)

Connect the socket

Parameters:
terminatedTrue if false is returned and the socket was terminated while connecting
newAddrOptional address to connect to
newPortOptional port to connect to
Returns:
False on failure
const String& error ( ) const [inline]

Get last connect/send/receive error text

Returns:
Last error text
bool recv ( char *  buffer,
unsigned int &  len 
)

Read data from socket

Parameters:
bufferDestination buffer
lenThe number of bytes to read. On exit contains the number of bytes actually read
Returns:
False on socket error
bool send ( const char *  buffer,
unsigned int &  len 
)

Write data to socket

Parameters:
bufferSource buffer
lenThe number of bytes to send
Returns:
False on socket error
void terminate ( bool  shutdown = false)

Terminate the socket

Parameters:
shutdownTrue to shut down, false to asynchronously terminate the socket
bool valid ( ) const [inline]

Check if the socket is valid

Returns:
True if the socket is valid.

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