GithubHelp home page GithubHelp logo

masesk / easy-socket Goto Github PK

View Code? Open in Web Editor NEW
64.0 4.0 13.0 45 KB

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

C++ 69.34% CMake 30.66%
cpp socket socket-programming network library c os-agnostic socket-library

easy-socket's People

Contributors

developerpaul123 avatar masesk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

easy-socket's Issues

Fix the readme

  • Add an example of how to use the library wrapper in the read me
  • Add instructions on how to build and include for Linux
  • Fix std to masesk for using namespace example

Client Receiving Data

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.

socketConnect() exception handling issue

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.