26 #ifndef yaSSL_SOCKET_WRAPPER_HPP
27 #define yaSSL_SOCKET_WRAPPER_HPP
34 #include <sys/types.h>
35 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
44 typedef unsigned int uint;
47 typedef SOCKET socket_t;
50 const socket_t INVALID_SOCKET = -1;
51 const int SD_RECEIVE = 0;
52 const int SD_SEND = 1;
53 const int SD_BOTH = 2;
54 const int SOCKET_ERROR = -1;
58 #include "openssl/transport_types.h"
61 typedef unsigned char byte;
70 yaSSL_send_func_t send_func_;
71 yaSSL_recv_func_t recv_func_;
73 explicit Socket(socket_t s = INVALID_SOCKET);
76 void set_fd(socket_t s);
77 uint get_ready()
const;
78 socket_t get_fd()
const;
80 void set_transport_ptr(
void *ptr);
81 void set_transport_recv_function(yaSSL_recv_func_t recv_func);
82 void set_transport_send_function(yaSSL_send_func_t send_func);
84 uint send(
const byte*
buf,
unsigned int len,
unsigned int& sent);
85 uint receive(byte* buf,
unsigned int len);
88 bool WouldBlock()
const;
89 bool IsNonBlocking()
const;
92 void shutDown(
int how = SD_SEND);
94 static int get_lastError();
95 static void set_lastError(
int error);
104 #endif // yaSSL_SOCKET_WRAPPER_HPP