#include <socket_wrapper.hpp>
Public Member Functions | |
| Socket (socket_t s=INVALID_SOCKET) | |
| ~Socket () | |
| void | set_fd (socket_t s) |
| uint | get_ready () const |
| socket_t | get_fd () const |
| uint | send (const byte *buf, unsigned int len, int flags=0) const |
| uint | receive (byte *buf, unsigned int len, int flags=0) |
| bool | wait () |
| bool | WouldBlock () const |
| void | closeSocket () |
| void | shutDown (int how=SD_SEND) |
Static Public Member Functions | |
| static int | get_lastError () |
| static void | set_lastError (int error) |
Private Member Functions | |
| Socket (const Socket &) | |
| Socket & | operator= (const Socket &) |
Private Attributes | |
| socket_t | socket_ |
| bool | wouldBlock_ |
Definition at line 71 of file socket_wrapper.hpp.
| yaSSL::Socket::Socket | ( | socket_t | s = INVALID_SOCKET |
) | [explicit] |
| yaSSL::Socket::~Socket | ( | ) |
Definition at line 81 of file socket_wrapper.cpp.
References closeSocket().
00082 { 00083 closeSocket(); 00084 }
Here is the call graph for this function:

| yaSSL::Socket::Socket | ( | const Socket & | ) | [private] |
| void yaSSL::Socket::closeSocket | ( | ) |
Definition at line 87 of file socket_wrapper.cpp.
References closesocket, yaSSL::INVALID_SOCKET, and socket_.
Referenced by yaSSL::SSL_clear(), yaSSL::SSL_shutdown(), and ~Socket().
00088 { 00089 if (socket_ != INVALID_SOCKET) { 00090 #ifdef _WIN32 00091 closesocket(socket_); 00092 #else 00093 close(socket_); 00094 #endif 00095 socket_ = INVALID_SOCKET; 00096 } 00097 }
Here is the caller graph for this function:

| socket_t yaSSL::Socket::get_fd | ( | ) | const |
Definition at line 75 of file socket_wrapper.cpp.
References socket_.
Referenced by yaSSL::SSL_accept(), yaSSL::SSL_connect(), and yaSSL::SSL_shutdown().
00076 { 00077 return socket_; 00078 }
Here is the caller graph for this function:

| int yaSSL::Socket::get_lastError | ( | ) | [static] |
Definition at line 176 of file socket_wrapper.cpp.
References errno.
Referenced by receive().
00177 { 00178 #ifdef _WIN32 00179 return WSAGetLastError(); 00180 #else 00181 return errno; 00182 #endif 00183 }
Here is the caller graph for this function:

| uint yaSSL::Socket::get_ready | ( | ) | const |
Definition at line 100 of file socket_wrapper.cpp.
References socket_.
Referenced by yaSSL::DoProcessReply().
00101 { 00102 #ifdef _WIN32 00103 unsigned long ready = 0; 00104 ioctlsocket(socket_, FIONREAD, &ready); 00105 #else 00106 /* 00107 64-bit Solaris requires the variable passed to 00108 FIONREAD be a 32-bit value. 00109 */ 00110 unsigned int ready = 0; 00111 ioctl(socket_, FIONREAD, &ready); 00112 #endif 00113 00114 return ready; 00115 }
Here is the caller graph for this function:

Definition at line 139 of file socket_wrapper.cpp.
References assert, get_lastError(), yaSSL::INVALID_SOCKET, socket_, SOCKET_EAGAIN, SOCKET_EWOULDBLOCK, and wouldBlock_.
Referenced by yaSSL::DoProcessReply(), and wait().
00140 { 00141 assert(socket_ != INVALID_SOCKET); 00142 wouldBlock_ = false; 00143 00144 int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags); 00145 00146 // idea to seperate error from would block by arnetheduck@gmail.com 00147 if (recvd == -1) { 00148 if (get_lastError() == SOCKET_EWOULDBLOCK || 00149 get_lastError() == SOCKET_EAGAIN) { 00150 wouldBlock_ = true; 00151 return 0; 00152 } 00153 } 00154 else if (recvd == 0) 00155 return static_cast<uint>(-1); 00156 00157 return recvd; 00158 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file socket_wrapper.cpp.
References assert, yaSSL::INVALID_SOCKET, pos(), and socket_.
Referenced by yaSSL::SSL::Send().
00119 { 00120 const byte* pos = buf; 00121 const byte* end = pos + sz; 00122 00123 assert(socket_ != INVALID_SOCKET); 00124 00125 while (pos != end) { 00126 int sent = ::send(socket_, reinterpret_cast<const char *>(pos), 00127 static_cast<int>(end - pos), flags); 00128 00129 if (sent == -1) 00130 return 0; 00131 00132 pos += sent; 00133 } 00134 00135 return sz; 00136 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void yaSSL::Socket::set_fd | ( | socket_t | s | ) |
Definition at line 69 of file socket_wrapper.cpp.
References socket_.
Referenced by yaSSL::SSL_set_fd().
00070 { 00071 socket_ = s; 00072 }
Here is the caller graph for this function:

| void yaSSL::Socket::set_lastError | ( | int | error | ) | [static] |
Definition at line 192 of file socket_wrapper.cpp.
References errno.
00193 { 00194 #ifdef _WIN32 00195 WSASetLastError(errorCode); 00196 #else 00197 errno = errorCode; 00198 #endif 00199 }
| void yaSSL::Socket::shutDown | ( | int | how = SD_SEND |
) |
Definition at line 169 of file socket_wrapper.cpp.
References assert, yaSSL::INVALID_SOCKET, and socket_.
00170 { 00171 assert(socket_ != INVALID_SOCKET); 00172 shutdown(socket_, how); 00173 }
| bool yaSSL::Socket::wait | ( | ) |
Definition at line 162 of file socket_wrapper.cpp.
References receive().
Referenced by yaSSL::DoProcessReply().
Here is the call graph for this function:

Here is the caller graph for this function:

| bool yaSSL::Socket::WouldBlock | ( | ) | const |
Definition at line 186 of file socket_wrapper.cpp.
References wouldBlock_.
Referenced by yaSSL::receiveData().
00187 { 00188 return wouldBlock_; 00189 }
Here is the caller graph for this function:

socket_t yaSSL::Socket::socket_ [private] |
Definition at line 72 of file socket_wrapper.hpp.
Referenced by closeSocket(), get_fd(), get_ready(), receive(), send(), set_fd(), and shutDown().
bool yaSSL::Socket::wouldBlock_ [private] |
1.4.7

