Demo for a friend of sockets working cross platform with plibsys.
The project is set to go, including the plibsys conmpiled libraries, for MSVC 2017 and gcc (Linux Mint 18). It's a CMake project. Thing is, plibsys has one header file (plibsysconfig.h) that is generated by plibsys's CMake build process as its compiled. Effectively this means this header is platform specific. The hack solution for now is that I include all the config files in plibsys_configs and you have to rename and copy the right one in. There are a lot of other better solutions, but they can vary immensely so didn't see the point in a a demo project -- in the real thing you could literally integrate the plibsys project as a git submodule and let its cmake build if you wanted.
- Go to libs/plibsys, and delete the plibsysconfig.h file currently there.
- Go to the libs/plibsys_configs directory. Copy the file appropriate for your platform to libs/plibsys, and rename file to "plibsysconfig.h".
- Compile as per standard for CMake project.
In this instance, I created a single exe that can function as either the server or a client (you specify). There should never be more than one server, I'm hardcoding ports here! Run the generated executable, selecting the first instance to be a server (it will prompt you when you run). Then run another instance in a seperate terminal, and select client. You can run client however many times, the server will just keep serving them. The server is an infinite loop so must terminate via ctrl-c.
- The plibsys documentation on networking says that the client side should call bind(). In this example I do not -- this was intentional. Calling bind on the client side is actually rarely ever necessary. Typically only ever done if you care about the port the client side binds to (which rarely ever happens -- typically on networks where only certain ports are open, etc.)