115 Commits

Author SHA1 Message Date
Cloaked9000
8ec22b7c56 Windows compatability fixes 2017-02-15 14:29:05 +00:00
Cloaked9000
9c520c3a0b Disable SIGPIPE, should disconnect socket now instead 2017-02-14 17:04:21 +00:00
Cloaked9000
11fac2aa12 Merged branch master into master 2017-02-10 10:56:14 +00:00
Cloaked9000
7fccf5dda4 Added more HTTP status codes. Added packet read/write raw. 2017-02-10 10:56:08 +00:00
Cloaked9000
a50529bf90 Update README.md 2017-02-02 12:00:09 +00:00
Cloaked9000
5c021761a8 Merged branch master into master 2017-02-02 11:51:43 +00:00
Cloaked9000
5c94b3f6df Added 'fr::Packetable' to allow custom objects to be packed into packets
Can be used by inheriting the 'pack' and 'unpack' members of fr::Packetable. The 'pack' function should add your class members to the packet, and the 'unpack' function should take them back out.
2017-02-02 11:51:31 +00:00
Cloaked9000
1251c303db Removed needless default constructor 2017-01-30 12:09:26 +00:00
Cloaked9000
cc68e4d32d Added missing header 2017-01-30 12:04:55 +00:00
Cloaked9000
fcef4e7164 Update CMakeLists.txt 2017-01-30 11:43:41 +00:00
Cloaked9000
15d20388c1 Added more type support to fr::Packet
Added std::pair<> support.

Added enum/enum class support
2017-01-27 15:36:36 +00:00
Fred Nicolson
24195e402f Bug fixes
Fixed deadlock in fr::Socket::receive.

Fixed fr::Packet's second constructor not delegating to first, causing it's intenal buffer to remain unitialised.
2017-01-26 21:58:20 +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
7691ed0a76 Added uint8_t support for packets 2017-01-23 17:56:20 +00:00
Cloaked9000
78098c7d32 Merged branch master into master 2017-01-23 09:15:44 +00:00
Cloaked9000
657c8e21ad Mutex changes 2017-01-23 09:15:40 +00:00
Fred Nicolson
6b2947932a Bux fixes
Fixed typo causing fr::Packet string extraction to fail.
Fixed Windows compilation error.
2017-01-22 14:20:24 +00:00
Fred Nicolson
f8aa22d223 Performance improvements and fixes
Greatly improvded fr::Packet>> performance.
Added buffer overflow protection to fr::Packet>>.
Added fr::Packet::reset_read_cursor to reset the packet data read position back to the beginning.
2017-01-22 12:11:17 +00:00
Cloaked9000
64f35e2a92 Increased receive chunk size to 4096 bytes 2017-01-13 15:30:11 +00:00
Cloaked9000
db6c7e4c41 Added support for sending and receiving of std::vectors
Provided that in std::vector<T>, T is a supported packet type (std::string, uintXX_t, intXX_t....)
2017-01-10 15:21:34 +00:00
Cloaked9000
02ab3634c4 Fixed Windows SocketSelector Exception
In Windows, if fr::SocketSelector::wait(...) was called, and the socket selector was empty, then an exception would be thrown as a result of Windows behaving differently to UNIX sockets. Now, the call will sleep for timeout before returning false, to match UNIX behaviour.
2017-01-06 16:15:04 +00:00
Cloaked9000
f0894e9d35 Merged branch master into master 2017-01-06 15:22:34 +00:00
Cloaked9000
e60d961fb0 Windows compatibility fixes 2017-01-06 15:22:22 +00:00
Cloaked9000
c0b84b55ee Windows compatability fixes 2017-01-06 15:21:17 +00:00
Cloaked9000
1594d4babf Added signed types to packet 2017-01-03 18:10:26 +00:00
Fred Nicolson
27b559b4ef Added URL encoding/decoding and proper POST parsing
Also fixed last body line being ignored in requests
2016-12-31 22:05:44 +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
8a54e8994a Fixed read_raw buffer issues (properly this time).
Also added '<<' overload on Packet for char*
2016-12-21 17:57:39 +00:00
Cloaked9000
f74f1f1a94 Bug fixes. Better syntax.
SocketReactor actually calls callbacks.

receive_all no longer tries to access out of bound array indexes.

fr::Packet constructor can now take as many arguments as you like and they'll be added to it automatically.

Added bool fr::Packet<< operator overload.
2016-12-20 18:02:59 +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
7017b64a15 Moved fr::TcpSocket::shutdown to fr::Socket::shutdown 2016-12-20 10:12:13 +00:00
Cloaked9000
9db918c7c2 Added fr::TcpSocket::shutdown to shutdown a socket 2016-12-20 10:07:40 +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
Fred Nicolson
9479029c87 Improved CMake build system. Updated readme.
The CMake build system now uses a relative path for modules, and supports a 'USE_SSL' option to optionally link in mbedtls and enable SSL support.

The readme now provides SSL examples.
2016-12-16 22:34:36 +00:00
Cloaked9000
8c94c337e9 SSL Contexts are now shared between sockets 2016-12-16 14:55:41 +00:00
Cloaked9000
509b37095f Added support for passing SSL cert info to listener 2016-12-15 17:59:39 +00:00
Cloaked9000
7d3e0fe5c8 Bug fixes & updated SocketSelector example. 2016-12-15 15:47:19 +00:00
Cloaked9000
2aeff56569 Merged branch master into master 2016-12-15 14:57:05 +00:00
Cloaked9000
69d183ed18 Code refactoring 2016-12-15 14:57:01 +00:00
Cloaked9000
34abd12414 Update README.md 2016-12-15 12:31:33 +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
Cloaked9000
51291e2cc3 More experimental SSL code
Added SSLSocket, which can actually send/receive encrypted data.

Started adding SSLListener. It doesn't fully work yet.
2016-12-13 18:03:56 +00:00
Cloaked9000
7e9f007acd TLS Test Code 2016-12-12 18:03:27 +00:00
Cloaked9000
bbd6ee071b Added missing code to readme 2016-12-12 14:33:36 +00:00
Fred Nicolson
91921867fa Updated send/receive documentation. Updated readme. 2016-12-11 20:54:31 +00:00
Fred Nicolson
27a88febfa Added ability to toggle socket blocking mode 2016-12-11 20:45:13 +00:00
Cloaked9000
eec630ed24 Update README.md 2016-12-11 20:02:15 +00:00