#include <faith/socket.h>
Inheritance diagram for Faith::Socket:

Public Types | |
| NoError | |
| System | |
| InvalidAddress | |
| ConnectionRefused | |
| Unreachable | |
| enum | SocketError { NoError, System, InvalidAddress, ConnectionRefused, Unreachable } |
Public Slots | |
| void | connect () |
| void | close () |
Signals | |
| void | connected () |
| void | connectFailed () |
| void | canRead () |
| void | canWrite () |
| void | peerDisconnected () |
Public Member Functions | |
| Socket (const Faith::String &address, int port, Object *parent=0) | |
| Socket (int fd, Object *parent=0) | |
| Socket (Object *parent=0) | |
| ~Socket () | |
| SocketError | error () const |
| void | setPeer (const Faith::String &address, int port) |
| Faith::String | peer () const |
| int | read (void *data, int count) |
| int | write (const void *data, int count) |
| bool | isClosed () const |
| bool | isConnected () const |
| bool | isConnectionFailed () const |
| bool | hasData () const |
| Faith::Socket::Socket | ( | const Faith::String & | address, | |
| int | port, | |||
| Object * | parent = 0 | |||
| ) |
connects to the address address and the port port
The actual connection doesn't occur until connect() is called
| Faith::Socket::Socket | ( | int | fd, | |
| Object * | parent = 0 | |||
| ) |
creates a socket from the given file descriptor, which is already open and connected
| Faith::Socket::Socket | ( | Object * | parent = 0 |
) |
| Faith::Socket::~Socket | ( | ) |
closes the socket if it is open
| void Faith::Socket::canRead | ( | ) | [signal] |
| void Faith::Socket::canWrite | ( | ) | [signal] |
| void Faith::Socket::close | ( | ) | [slot] |
Terminate the call. The other end will be told after having recieved all that was written
| void Faith::Socket::connect | ( | ) | [slot] |
begins the connection to the peer
This function will emit connected or connectFailed when it is done
| void Faith::Socket::connected | ( | ) | [signal] |
| void Faith::Socket::connectFailed | ( | ) | [signal] |
| SocketError Faith::Socket::error | ( | ) | const [inline] |
| bool Faith::Socket::hasData | ( | ) | const |
| bool Faith::Socket::isClosed | ( | ) | const |
| bool Faith::Socket::isConnected | ( | ) | const |
There is another end connected
| bool Faith::Socket::isConnectionFailed | ( | ) | const |
The connection has failed (and connectFailed was emitted
| Faith::String Faith::Socket::peer | ( | ) | const |
| void Faith::Socket::peerDisconnected | ( | ) | [signal] |
emitted when the other end disconnects (before you do, that is) (The next read will return 0)
| int Faith::Socket::read | ( | void * | data, | |
| int | count | |||
| ) |
reads from the socket into data
this is a non-blocking operation, so if data is not immediately available, a value less than count may be returned (even 0)
| data | is the array to write into, it has a size of at length count | |
| count | is the number of bytes to read |
| void Faith::Socket::setPeer | ( | const Faith::String & | address, | |
| int | port | |||
| ) |
sets the address to connect to
| int Faith::Socket::write | ( | const void * | data, | |
| int | count | |||
| ) |
writes into the socket from data
This is non-blocking, so it may not write all the data specified, returning how much actually was written
| data | is the array to read the data from, it has a size no smaller than count | |
| count | the number of bytes to attempt to write |
1.4.7