Base socket handler for all TCP sockets. More...
#include <tcp.h>
Public Member Functions | |
| bool | IsConnected () const |
| Whether this socket is currently bound to a socket. | |
| virtual NetworkRecvStatus | CloseConnection (bool error=true) |
| Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped. | |
| virtual void | SendPacket (Packet *packet) |
| This function puts the packet in the send-queue and it is send as soon as possible. | |
| SendPacketsState | SendPackets (bool closing_down=false) |
| Sends all the buffered packets out for this client. | |
| virtual Packet * | ReceivePacket () |
| Receives a packet for the given client. | |
| bool | CanSendReceive () |
| Check whether this socket can send or receive something. | |
| NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
Data Fields | |
| SOCKET | sock |
| The socket currently connected to. | |
| bool | writable |
| Can we write to this socket? | |
Private Attributes | |
| Packet * | packet_queue |
| Packets that are awaiting delivery. | |
| Packet * | packet_recv |
| Partially received packet. | |
Base socket handler for all TCP sockets.
Definition at line 31 of file tcp.h.
| bool NetworkTCPSocketHandler::CanSendReceive | ( | ) |
Check whether this socket can send or receive something.
true when there is something to receive. Definition at line 224 of file tcp.cpp.
References sock, and writable.
Referenced by ClientNetworkGameSocketHandler::Receive(), and ClientNetworkContentSocketHandler::SendReceive().
| NetworkRecvStatus NetworkTCPSocketHandler::CloseConnection | ( | bool | error = true |
) | [virtual] |
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped.
| error | Whether we quit under an error condition or not. |
Reimplemented from NetworkSocketHandler.
Reimplemented in NetworkAdminSocketHandler, and NetworkGameSocketHandler.
Definition at line 36 of file tcp.cpp.
References Packet::next, packet_queue, packet_recv, and writable.
Referenced by NetworkContentSocketHandler::Close(), ReceivePacket(), and SendPackets().
| bool NetworkTCPSocketHandler::IsConnected | ( | ) | const [inline] |
Whether this socket is currently bound to a socket.
Definition at line 43 of file tcp.h.
References sock.
Referenced by ReceivePacket(), and SendPackets().
| Packet * NetworkTCPSocketHandler::ReceivePacket | ( | ) | [virtual] |
Receives a packet for the given client.
| status | the variable to store the status into |
Definition at line 144 of file tcp.cpp.
References Packet::buffer, CloseConnection(), DEBUG, IsConnected(), packet_recv, Packet::pos, Packet::PrepareToRead(), Packet::ReadRawPacketSize(), SEND_MTU, Packet::size, and sock.
Referenced by NetworkGameSocketHandler::ReceivePackets(), NetworkContentSocketHandler::ReceivePackets(), and NetworkAdminSocketHandler::ReceivePackets().
| void NetworkTCPSocketHandler::SendPacket | ( | Packet * | packet | ) | [virtual] |
This function puts the packet in the send-queue and it is send as soon as possible.
This is the next tick, or maybe one tick later if the OS-network-buffer is full)
| packet | the packet to send |
Definition at line 59 of file tcp.cpp.
References Packet::buffer, Packet::next, packet_queue, Packet::PrepareToSend(), ReallocT(), and Packet::size.
Referenced by ServerNetworkAdminSocketHandler::SendClientInfo().
| SendPacketsState NetworkTCPSocketHandler::SendPackets | ( | bool | closing_down = false |
) |
Sends all the buffered packets out for this client.
It stops when: 1) all packets are send (queue is empty) 2) the OS reports back that it can not send any more data right now (full network-buffer, it happens ;)) 3) sending took too long
| closing_down | Whether we are closing down the connection. |
true if a (part of a) packet could be sent and the connection is not closed yet. Definition at line 93 of file tcp.cpp.
References Packet::buffer, CloseConnection(), DEBUG, IsConnected(), Packet::next, packet_queue, Packet::pos, Packet::size, sock, and writable.
Referenced by NetworkDisconnect(), ClientNetworkGameSocketHandler::Send(), ServerNetworkAdminSocketHandler::Send(), and ClientNetworkContentSocketHandler::SendReceive().
1.7.1