|
MoSync 3.3
|
An Environment-based communications class. Encapsulates MoSync's basic connection system, which supports, for example, TCP, HTTP and Bluetooth. More...
#include <MAUtil/Connection.h>
Public Member Functions | |
| Connection (ConnectionListener *listener, MAHandle conn=0) | |
| virtual | ~Connection () |
| int | connect (const char *url) |
| void | close () |
| void | write (const void *src, int len) |
| void | writeFromData (MAHandle data, int offset, int len) |
| void | writeTo (const void *src, int len, const MAConnAddr &dst) |
| void | recv (void *dst, int maxlen) |
| void | recvToData (MAHandle data, int offset, int maxlen) |
| void | recvFrom (void *dst, int maxlen, MAConnAddr *src) |
| void | read (void *dst, int len) |
| void | readToData (MAHandle data, int offset, int len) |
| void | setListener (ConnectionListener *listener) |
| bool | isOpen () const |
| int | getAddr (MAConnAddr *dst) |
Protected Member Functions | |
| void | recvMem (int prevRes) |
| void | recvData (int prevRes) |
| virtual void | connEvent (const MAConnEventData &data) |
Protected Attributes | |
| MAHandle | mConn |
| ConnectionListener * | mListener |
| int | mRemain |
| byte * | mDst |
| MAHandle | mData |
| int | mOffset |
| void(Connection::* | mRecv )(int prevRes) |
An Environment-based communications class. Encapsulates MoSync's basic connection system, which supports, for example, TCP, HTTP and Bluetooth.
| MAUtil::Connection::Connection | ( | ConnectionListener * | listener, |
| MAHandle | conn = 0 |
||
| ) |
| listener | Will recieve events from this Connection. |
| conn | Optional. If you have a connection handle, you can pass it here to wrap it in a Connection. |
| virtual MAUtil::Connection::~Connection | ( | ) | [virtual] |
Closes the connection, if open.
| int MAUtil::Connection::connect | ( | const char * | url | ) |
Reimplemented in MAUtil::BluetoothConnection.
| void MAUtil::Connection::close | ( | ) |
Closes the connection, if open. Frees all resources allocated by this object. Allows this Connection object to be reused for further connections.
Reimplemented in MAUtil::BluetoothConnection.
| void MAUtil::Connection::write | ( | const void * | src, |
| int | len | ||
| ) |
Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.
| void MAUtil::Connection::writeFromData | ( | MAHandle | data, |
| int | offset, | ||
| int | len | ||
| ) |
Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.
| void MAUtil::Connection::writeTo | ( | const void * | src, |
| int | len, | ||
| const MAConnAddr & | dst | ||
| ) |
Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.
| void MAUtil::Connection::recv | ( | void * | dst, |
| int | maxlen | ||
| ) |
Reads between 1 and maxlen bytes to dst. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete. Use this function when you don't care how much data you get, as long as you get something.
| void MAUtil::Connection::recvToData | ( | MAHandle | data, |
| int | offset, | ||
| int | maxlen | ||
| ) |
Reads between 1 and maxlen bytes to data, starting at offset. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete.
| void MAUtil::Connection::recvFrom | ( | void * | dst, |
| int | maxlen, | ||
| MAConnAddr * | src | ||
| ) |
Reads between 1 and maxlen bytes to dst. Stores the sender address in src. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete.
| void MAUtil::Connection::read | ( | void * | dst, |
| int | len | ||
| ) |
Reads exactly len bytes to dst. Causes ConnectionListener::connReadFinished() to be called when the operation is complete. Use this function when you know exactly how much data you want, and are not interested in anything less.
| void MAUtil::Connection::readToData | ( | MAHandle | data, |
| int | offset, | ||
| int | len | ||
| ) |
Reads exactly len bytes to data, starting at offset. Causes ConnectionListener::connReadFinished() to be called when the operation is complete.
| void MAUtil::Connection::setListener | ( | ConnectionListener * | listener | ) |
Replaces the listener for this object.
| bool MAUtil::Connection::isOpen | ( | ) | const |
Returns true if the connection is open, false otherwise. The connection is considered open even during the connect() operation.
| int MAUtil::Connection::getAddr | ( | MAConnAddr * | dst | ) |
Retrieves the remote address of this connection.
| void MAUtil::Connection::recvMem | ( | int | prevRes | ) | [protected] |
| void MAUtil::Connection::recvData | ( | int | prevRes | ) | [protected] |
| virtual void MAUtil::Connection::connEvent | ( | const MAConnEventData & | data | ) | [protected, virtual] |
Implements MAUtil::ConnListener.
Reimplemented in MAUtil::HttpConnection.
MAHandle MAUtil::Connection::mConn [protected] |
ConnectionListener* MAUtil::Connection::mListener [protected] |
int MAUtil::Connection::mRemain [protected] |
byte* MAUtil::Connection::mDst [protected] |
MAHandle MAUtil::Connection::mData [protected] |
int MAUtil::Connection::mOffset [protected] |
void(Connection::* MAUtil::Connection::mRecv)(int prevRes) [protected] |