xorp

SocketClient Class Reference

Inheritance diagram for SocketClient:
Socket

List of all members.

Public Types

enum  Event { DATA = AsyncFileWriter::DATA, FLUSHING = AsyncFileWriter::FLUSHING, ERROR = AsyncFileWriter::OS_ERROR }
typedef XorpCallback1< void,
bool >::RefPtr 
ConnectCallback
 Callback for connection attempts.
typedef XorpCallback4< bool,
BGPPacket::Status, const
uint8_t *, size_t,
SocketClient * >::RefPtr 
MessageCallback
 Callback for incoming data.
typedef XorpCallback2< void,
Event, const uint8_t * >
::RefPtr 
SendCompleteCallback
 Callback for data transmission.

Public Member Functions

 SocketClient (const Iptuple &iptuple, EventLoop &e, bool md5sig=false)
void connect (ConnectCallback cb)
 Asynchronously connect.
void connect_break ()
 Break asynchronous connect attempt.
void connected (XorpFd s)
 The peer has initiated the connection so form an association.
void flush_transmit_queue ()
 Throw away all the data that is queued to be sent on this socket.
void stop_reader ()
 Stop reading data on this socket.
void disconnect ()
 Disconnect this socket.
bool disconnecting ()
void set_callback (const MessageCallback &cb)
 Set the callback for incoming data.
bool send_message (const uint8_t *buf, size_t cnt, SendCompleteCallback cb)
 Asynchronously Send a message.
bool output_queue_busy () const
 Flow control signal.
int output_queue_size () const
bool is_connected ()
bool still_reading ()

Private Member Functions

void connect_socket (XorpFd sock, string raddr, uint16_t port, string laddr, ConnectCallback cb)
void connect_socket_complete (XorpFd fd, IoEventType type, ConnectCallback cb)
void connect_socket_break ()
void async_add (XorpFd sock)
void async_remove ()
void async_remove_reader ()
void read_from_server (XorpFd sock)
void write_to_server (XorpFd sock)
void send_message_complete (AsyncFileWriter::Event e, const uint8_t *buf, const size_t buf_bytes, const size_t offset, SendCompleteCallback cb)
void async_read_start (size_t cnt=BGPPacket::COMMON_HEADER_LEN, size_t ofset=0)
void async_read_message (AsyncFileWriter::Event ev, const uint8_t *buf, const size_t buf_bytes, const size_t offset)

Private Attributes

MessageCallback _callback
AsyncFileWriter_async_writer
AsyncFileReader_async_reader
bool _disconnecting
bool _connecting
bool _md5sig
uint8_t _read_buf [BGPPacket::MAXPACKETSIZE]

Member Typedef Documentation

typedef XorpCallback4<bool,BGPPacket::Status,const uint8_t*,size_t, SocketClient*>::RefPtr SocketClient::MessageCallback

Callback for incoming data.

Parameters:
constuint8_t* pointer to data.
size_tlength of data.
typedef XorpCallback2<void,Event,const uint8_t*>::RefPtr SocketClient::SendCompleteCallback

Callback for data transmission.

Parameters:
Eventstatus of the send.
constuint8_t* pointer to the transmitted data. Allows caller to free the data.

Constructor & Destructor Documentation

SocketClient::SocketClient ( const Iptuple iptuple,
EventLoop e,
bool  md5sig = false 
)
Parameters:
iptuplespecification of the connection endpoints.

Member Function Documentation

void SocketClient::connect ( ConnectCallback  cb)

Asynchronously connect.

Parameters:
cbis called when connection suceeds or fails.
void SocketClient::connect_break ( )

Break asynchronous connect attempt.

Each instance of the this class has a single connection associated with it. If while we are attemping to connect to a peer (using connect()), the peer connects to us. It is necessary to stop the outgoing connect.

void SocketClient::connected ( XorpFd  s)

The peer has initiated the connection so form an association.

Parameters:
sincoming socket file descriptor
bool SocketClient::disconnecting ( ) [inline]
Returns:
Are we currrent disconecting.
bool SocketClient::is_connected ( )
Returns:
true if a session exists.
bool SocketClient::output_queue_busy ( ) const

Flow control signal.

Data will be queued for transmission until a resource such as memory is exceeded. A correctly written client should stop sending messages if the output queue is not draining.

Returns:
true if its time to stop sending messages.
int SocketClient::output_queue_size ( ) const
Returns:
number of messages in the output queue.
bool SocketClient::send_message ( const uint8_t *  buf,
size_t  cnt,
SendCompleteCallback  cb 
)

Asynchronously Send a message.

Parameters:
bufpointer to data buffer.
cntlength of data buffer.
cbnotification of success or failure.
Returns:
true if the message is accepted.
bool SocketClient::still_reading ( )
Returns:
true if we are still reading.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations