4
(c) Richard Thrippleton
5
Licensing terms are in the 'LICENSE' file
6
If that file is not included with this source then permission is not given to use this source in any way whatsoever.
10
class sockhelper //Class that helps with socket operations, giving them much easier non-blocking semantics
13
sockhelper(TCPsocket sock); //Constructor, give it the socket to help with
14
~sockhelper(); //Destructor, cleans up any dynamic data
16
void pump(); //Pump scheduled outgoing data, fill incoming buffer
17
void send(unsigned char* data,int len); //Schedule data of given length to be sent
18
unsigned char* request(int len); //Request incoming data of given length, returns null if not enough in the buffer
19
void suck(); //Way to roll on the stream after a request has been used and totally done with
20
long getcount(); //Get the socket throughput byte count, and reset it to zero
23
static Uint32 alarmcallback(Uint32 dly,void* from); //Callback handling the alarm when pumping blocks for too long
24
TCPsocket sock; //Socket to help with
25
SDLNet_SocketSet poll; //For polling input
26
unsigned char in[2048]; //Input buffer
27
int ins; //Size of input buffer used
28
unsigned char out[1024]; //Output buffer
29
int outs; //Size of output buffer used
30
int take; //Record how much was requested (for the suck operation)
31
long cnt; //Count of bytes come through the socket
32
SDL_TimerID alrm; //The blocking alarm being set
33
bool blck; //Flag to indicate that the socket outgoing has blocked and should be deleted as soon as safe