Post: C++ Easy Socket - A custom socket class
05-11-2016, 02:11 AM #1
Specter
Pro Memer
(adsbygoogle = window.adsbygoogle || []).push({}); Introduction

Hello NGU, I was lately working on a console IRC client using C++, and realized unix sockets in C suck. You have to go through a lot of work and lots of messy stuff to even get a connection established, so I wrote a little class that allows you to use a socket easily, and the class does all the dirty work for you. Now currently, I don't believe this works for Windows, however I will add support for it in the future (it does however work in linux environments like cygwin). It can also only currently be used for client -> server connections, though I also hope to integrate support for other functions in the near future such as bind(). If any of you want to help out with this, go ahead and fork the repo, if it's good I'll implement it into the official branch!


Documentation

The GitHub README has a lot of the documentation, however there's more documentation in the pdf file in /docs. The code is also documented, the header file contains an outline of the class and the implementation is well commented, even with function documentation. In the PDF there is also example usage, and there's an example of it's usage in main.cpp found in /src. In case you're lazy, I've provided a code snippet of the README.md below.

    # C++ Easy Socket
The “C++ Easy Socket” project was developed to make networking projects easier
by hiding all of the messy difficult stuff. It provides a higher-level of abstraction
without compromising portability in regards to libraries. It’s currently been built
and coded for Linux, however Windows compatibility will come in the near future,
as well as support for server-sided functions (eg. binding). If anyone out there
wants to help out by implementing either of these, feel free to fork the repo, I
may even put it in the official branch!

# Motivation
This class was originally implemented for an IRC client I was creating in C++. After
seeing all the code and messing around it took to use sockets, I decided to write
my own class. After I implemented the program it occurred to me this might be of
use to others. It’s by no means perfect, but improvements will be made over
time.

# Latest Version
The latest version for this project is 1.0. Further implementation such as server
support and windows support will be added in the near future.

# Requirements
This project does not require any external libraries, all you need is gcc/g++ or any
other compiler to compile the source code.

# License
C++ Easy Socket is distributed under the Apache License, meaning you are free to
modify, distribute, and use for commercial/private use, however the developers
of C++ Easy Socket will not be held liable. For more information, please view the
Apache v2.0 license before distribution or modification.

# More Documentation
Additional documentation can be found in /docs. The PDF will be updated with
any changes made to the library.




Criticism / Improvement

I would appreciate any constructive criticism with this GitHub project, it's always good to learn and get better. But please don't leave flame posts, though I doubt any of you would do so.


GitHub

The project is posted open-source on my GitHub, this is the You must login or register to view this content..


Conclusion

I hope some of you will find this useful for your own projects, and maybe you can help me out with it as well if you wish, go ahead and fork it. Now if you want to use this for PS3 SPRX projects, you're out of luck because Sony's compiler is really shit and won't even support <string> or <vector>, so it'd have to be heavily modified for it to work, and even then it probably still wouldn't work. Thanks a lot Sony. Happy networking!

The following 4 users say thank you to Specter for this useful post:

Jim Halpert, Kryptus, Mr Smithy x, Swaqq

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo