16 Commits

Author SHA1 Message Date
Fred Nicolson
dff81f495e Fixed memory leak
fr::SSLSocket did not call mbedtls_net_free. It called mbedtls_ssl_close_notify instead.
2017-07-31 11:58:22 +01:00
Fred Nicolson
d3b51f75a5 fr::SSLSocket bug fixes
Whilst receiving data, the SSL socket would not return if the remote socket disconnected, leading to it blocking indefinitely.

Whilst sending enough data to require multiple writes, the socket would disconnect instead of sending more. This has also been fixed.
2017-07-19 13:54:42 +01:00
miaodx
f1d1d0849e reorganize the include files according to the SSL_ENABLED flag.
So that we can build without ssl support.
2017-05-29 09:36:20 +08:00
Fred Nicolson
ae61464aee Removed is_connected flag in fr::Socket
The socket descriptor is now checked, to see if it's greater than 0, instead. This means that the flag doesn't have to be manually updated.
2017-05-25 16:21:39 +01:00
Cloaked9000
9c520c3a0b Disable SIGPIPE, should disconnect socket now instead 2017-02-14 17:04:21 +00:00
Fred Nicolson
2abe108d57 Merge fix 2017-01-25 22:59:56 +00:00
Fred Nicolson
fad7d0b81f Packet and socket optimisations
Sending/receiving data on a socket is roughly 5.5x faster, after removing data copies and buffer re-allocations.
2017-01-25 22:57:11 +00:00
Cloaked9000
657c8e21ad Mutex changes 2017-01-23 09:15:40 +00:00
Fred Nicolson
e0e956cf78 Socket::reconfigure_socket called on connection to apply options
'TCP_NODELAY' is set automatically on connection now.
2016-12-31 11:14:26 +00:00
Fred Nicolson
2a5d960e56 Added fr::Socket::has_data to check if recv buffer is empty
If using a SocketSelector, you should keep accepting data from the socket until has_data returns false, indicating that you've read everything.
2016-12-27 21:58:39 +00:00
Fred Nicolson
8638b70fb8 Thread safety for send/receive on both Tcp & SSL sockets
Send/Recv often needs to be called multiple times to transfer all of the data. send_raw/receive_raw are now mutex protected and so both send & receive can be called simultaneously.
2016-12-23 18:23:25 +00:00
Cloaked9000
70779fbe9c Added SocketReactor & fixes
Sockets will immediately return fr::Socket::Status::Disconnected if an attempt to send/receive data is made whilst the connection is closed.

Added SocketReactor, which is effectively a little wrapper around fr::SocketSelector, but can automatically call a callback for a socket when data is received on it.
2016-12-20 11:33:31 +00:00
Cloaked9000
2de9540819 Added windows support. Updated build system.
CMake build system builds as a library, not an executable now.

Windows is now supported and should work fine.
2016-12-19 12:10:39 +00:00
Cloaked9000
8c94c337e9 SSL Contexts are now shared between sockets 2016-12-16 14:55:41 +00:00
Cloaked9000
69d183ed18 Code refactoring 2016-12-15 14:57:01 +00:00
Cloaked9000
14fccb84c9 More work on SSL support.
You can now accept SSL connections using SSLListeners, and then send/receive data through the associated SSLSocket.

HttpSocket's now support both HTTP and HTTPS, using templates:

fr::HttpSocket<fr::SSLSocket> https_socket; 
fr::HttpSocket<fr::TcpSocket> http_socket;
2016-12-15 12:29:23 +00:00