#include <socket.h>
Collaboration diagram for hoa_socket::Socket:

Public Member Functions | |
| void | Connect (const std::string &host, uint16 port) |
| Connects to a server. | |
| void | Disconnect () |
| Disconnects from the server. | |
| bool | IsConnected () |
| Checks whether the socket is connected. | |
| bool | IsQueued (uint32 wait_time=0) |
| Checks if there is any incoming data in the queue. | |
| std::string | ReadLine () |
| Reads one line. | |
| uint32 | RecvBinary (void *location, uint32 maxlen) |
| Reads binary data. | |
| void | ScanLine (const char *format,...) |
| Scans one line, in scanf style. | |
| uint32 | SendBinary (void *data, uint32 len) |
| Sends binary data. | |
| Socket () | |
| Standard constructor. | |
| void | Write (const char *format,...) |
| Writes textual data. | |
| ~Socket () | |
| Standard destructor. | |
Private Attributes | |
| bool | connected |
| SDLNet_SocketSet | set |
| TCPsocket | sock |
****************************************************************************
TCP client socket with basic connectivity functionality.
Definition at line 41 of file socket.h.
| hoa_socket::Socket::Socket | ( | ) |
Standard constructor.
Initialises SDL_net if it is not already started, and creates a TCP socket
Definition at line 22 of file socket.cpp.
References connected, num_sockets, set, and sock.
| hoa_socket::Socket::~Socket | ( | ) |
Standard destructor.
Quits SDL_net if it is not needed, disconnects if the TCP socket is still connected
Definition at line 32 of file socket.cpp.
References Disconnect(), IsConnected(), and num_sockets.
Here is the call graph for this function:

| void hoa_socket::Socket::Connect | ( | const std::string & | host, | |
| uint16 | port | |||
| ) |
Connects to a server.
| host | The hostname to which to connect | |
| port | The TCP port number with which to connect |
Definition at line 46 of file socket.cpp.
References connected, set, and sock.
Referenced by hoa_utils::IsLatestVersion().
| void hoa_socket::Socket::Disconnect | ( | ) |
Disconnects from the server.
Definition at line 64 of file socket.cpp.
References connected, IsConnected(), set, and sock.
Referenced by hoa_utils::IsLatestVersion(), and ~Socket().
Here is the call graph for this function:

| bool hoa_socket::Socket::IsConnected | ( | ) |
Checks whether the socket is connected.
Definition at line 41 of file socket.cpp.
References connected.
Referenced by Disconnect(), hoa_utils::IsLatestVersion(), IsQueued(), RecvBinary(), SendBinary(), and ~Socket().
| bool hoa_socket::Socket::IsQueued | ( | uint32 | wait_time = 0 |
) |
Checks if there is any incoming data in the queue.
| wait_time | Time to wait for incoming data, in milliseconds |
Definition at line 73 of file socket.cpp.
References IsConnected(), and set.
Referenced by hoa_utils::IsLatestVersion().
Here is the call graph for this function:

| std::string hoa_socket::Socket::ReadLine | ( | ) |
Reads one line.
Definition at line 105 of file socket.cpp.
References RecvBinary().
Referenced by ScanLine().
Here is the call graph for this function:

Reads binary data.
| d | A pointer to the location in which to store the data | |
| len | The length of the data up to which to read |
Definition at line 85 of file socket.cpp.
References IsConnected(), and sock.
Referenced by ReadLine().
Here is the call graph for this function:

| void hoa_socket::Socket::ScanLine | ( | const char * | format, | |
| ... | ||||
| ) |
Scans one line, in scanf style.
| fmt | The format to scan | |
| ... | Other arguments, following from the scanf format given |
Definition at line 123 of file socket.cpp.
References ReadLine().
Referenced by hoa_utils::IsLatestVersion().
Here is the call graph for this function:

Sends binary data.
| d | A pointer to a block of data | |
| len | The number of bytes of data |
Definition at line 79 of file socket.cpp.
References IsConnected(), and sock.
Here is the call graph for this function:

| void hoa_socket::Socket::Write | ( | const char * | format, | |
| ... | ||||
| ) |
Writes textual data.
| fmt | The format of the data, in printf style | |
| ... | Other arguments, following from the format given (the format is a const char*, don't forget) |
Definition at line 91 of file socket.cpp.
Referenced by hoa_utils::IsLatestVersion().
bool hoa_socket::Socket::connected [private] |
Definition at line 46 of file socket.h.
Referenced by Connect(), Disconnect(), IsConnected(), and Socket().
SDLNet_SocketSet hoa_socket::Socket::set [private] |
Definition at line 45 of file socket.h.
Referenced by Connect(), Disconnect(), IsQueued(), and Socket().
TCPsocket hoa_socket::Socket::sock [private] |
Definition at line 44 of file socket.h.
Referenced by Connect(), Disconnect(), RecvBinary(), SendBinary(), and Socket().
1.5.1