1 /* IOSocket.h - IOMultiplexer v2
2 * Copyright (C) 2014 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef _IOSocket_cpp_h
18 #define _IOSocket_cpp_h
22 #include "../IOHandler/IOSockets.h"
33 int connect(char *hostname, unsigned int port, int ssl, char *bindhost);
34 int connect(char *hostname, unsigned int port, int ssl, char *bindhost, int flags);
36 int listen(char *hostname, unsigned int port);
37 int listen(char *hostname, unsigned int port, int flags);
38 int listen_ssl(char *hostname, unsigned int port, char *certfile, char *keyfile);
39 int listen_ssl(char *hostname, unsigned int port, char *certfile, char *keyfile, int flags);
41 void write(const char *data, int len);
42 void writef(const char *format, ...);
55 void socket_callback(IOSocketEvent *event);
57 virtual int recvEvent(const char *data, int len) { return len; };
58 virtual void recvLine(char *line) {};
59 void enableRecvLine();
60 void disableRecvLine();
62 virtual void connectedEvent() {};
63 virtual void notConnectedEvent(int errid) {};
64 virtual void closedEvent(int errid) {};
65 virtual void acceptedEvent(CIOSocket *client) { client->close(); };
66 virtual void dnsErrEvent(char *errormsg) {};
71 CIOSocket(IOSocket *iosocket);