masesk / easy-socket Goto Github PK
View Code? Open in Web Editor NEWModern C++ 11 native, OS agnostic, socket library/starting base with a single header include
Home Page: https://masesk.github.io
License: Apache License 2.0
Modern C++ 11 native, OS agnostic, socket library/starting base with a single header include
Home Page: https://masesk.github.io
License: Apache License 2.0
Since this library is intended to work on Windows/Linux, it might be prudent to add CMake support for the library so I can be built natively on Linux by users if they so choose. If this is desired I can file a PR.
Thanks!
When trying to use socketListen on the clients application the window stops responding. Is this because it is exclusively used for the server? Or am I able to use socketListen and socketSend on either side of the app. I am able to send the code but I will have to cut out a lot of the random other stuff since it's being used for a game.
I'm testing a simple client call.
To test the exception, I call socketConnect()
without an actual server to connect to.
But in my try/catch I am not able to catch the socket_error_exception. My code:
try
{
client->socketConnect("io_update", "127.0.0.1", 50051);
}
catch(const masesk::socket_error_exception& e)
{
return -3;
}
will just terminate the program, without catching anything.
I looked at your code:
void socketConnect(const std::string &channelName, const std::string &ip, std::uint16_t port)
{
if (sockInit() != 0)
{
throw masesk::socket_error_exception();
return;
}
SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET || sock == SOCKET_ERROR)
{
sockQuit();
throw masesk::socket_error_exception();
}
sockaddr_in hint;
hint.sin_family = AF_INET;
hint.sin_port = htons(port);
inet_pton(AF_INET, ip.c_str(), &hint.sin_addr);
int connResult = connect(sock, (sockaddr *)&hint, sizeof(hint));
if (connResult == SOCKET_ERROR)
{
sockClose(sock);
sockQuit();
throw socket_error_exception();
}
...
and noticed that sockQuit()
will actually return 0
before the throw. Would that be a problem?
Thanks
Everything passed to the wrapper should be a pass by const-referrence instead of pass-by value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.