easy-socket
easy-socket copied to clipboard
upgrade EasySocket
Improvements to the Original Library
Below is a summary of the enhancements made to the original library as indicated in the patch file:
-
Introduction of
stopFlagandlisteningSocket- A
std::atomic<bool> stopFlaghas been introduced to facilitate the stopping of the socket listening process in a thread-safe manner. - A
SOCKET listeningSockethas been introduced to hold the socket that is currently listening for incoming connections.
- A
-
Enhanced Error Handling
- The error handling has been improved to better manage socket errors and data size exceptions during the socket communication process.
-
Improved Socket Closure
- The
closeAllConnectionsmethod has been introduced to close all active connections and clear the respective maps holding the client and server sockets. - The
sockQuitfunction is called within thecloseAllConnectionsmethod to clean up the socket library after closing all connections.
- The
-
Improved Socket Sending and Receiving
- The
socketSendmethod has been updated to check both the client and server socket maps to find the appropriate socket associated with the channel name before sending data. - The
socketReceivemethod has been introduced to facilitate the receiving of data from a socket associated with a given channel name, with appropriate error handling and buffer management.
- The
-
Refined Socket Listening
- The
socketListenmethod has been refined to incorporate thestopFlagto allow for the graceful stopping of the listening process. - The method now handles the
SOCKET_ERRORmore gracefully, avoiding the throwing of exceptions in certain cases and instead opting for a loop continuation, allowing for more robust server operation.
- The
-
Better Management of Client and Server Sockets
- The client and server sockets are now stored in separate unordered maps, allowing for better organization and management of the sockets.
- The
socketSendandsocketReceivemethods have been updated to check both the client and server socket maps to find the correct socket associated with a given channel name, improving the flexibility of the socket communication process.
-
Introduction of New Exceptions
- A new exception,
masesk::invalid_socket_exception, has been introduced to handle cases where an invalid socket is encountered, enhancing the robustness of the error handling process.
- A new exception,
-
Code Cleanup and Organization
- The code has been reorganized and cleaned up to improve readability and maintainability.
- Redundant code has been removed, and the structure of the methods has been optimized for better performance and efficiency.