Giter Site home page Giter Site logo

dfhack / clsocket Goto Github PK

View Code? Open in Web Editor NEW
154.0 154.0 64.0 104 KB

SimpleSockets is a lightweight set of classes that allow developers to implement IP based network programs.

Home Page: http://sockets.carrierlabs.com/

CMake 2.67% C++ 88.99% C 8.34%
c-plus-plus socket

clsocket's Introduction

DFHack Readme

Build Status Documentation Status License Discord

DFHack is a Dwarf Fortress memory access library, distributed with scripts and plugins implementing a wide variety of useful functions and tools.

The full documentation is available online here. If you have DFHack installed, it is also accessible as raw text in the hack/docs folder. If you're an end-user, modder, or interested in contributing to DFHack -- go read those docs.

If the docs are unclear or you need more help, please check out our support page for ways to contact the DFHack developers.

clsocket's People

Contributors

ab9rf avatar benlubar avatar danaris avatar espenhw avatar hayguen avatar lethosor avatar myk002 avatar orrche avatar palakis avatar peterix avatar tc01 avatar tochlab avatar v-val 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clsocket's Issues

IPv6 support

If You can add surpport IPv6, it will be awesome~

EXPORT definition might collide easily

#define EXPORT __declspec(dllexport)

is defined in Host.h include from other public headers (SimpleSocket.h), with guard #ifdef _MSC_VER.
however this definition might collide easily with user code using CLsocket.

i'd suggest to rename EXPORT into CLSOCKET_EXPORT ..
[ and possibly make this definition only when having an additional private definition in CMakeLists.txt, e.g. when compiling the shared library ]

CMake integration available only after install

When trying to use clsocket without installing it (e.g. with FetchContent), include path is not set and compilation fails.
With following dummy example:
main.cpp:

#include <PassiveSocket.h>
int main() {}

CMakeLists.txt:

project(test_clsocket_cmake LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

include(FetchContent)
FetchContent_Declare(
    clsocket
    GIT_REPOSITORY https://github.com/DFHack/clsocket.git
)
option(CLSOCKET_SHARED Off)
option(CLSOCKET_DEP_ONLY Off)
FetchContent_MakeAvailable(clsocket)

set(app_ ${PROJECT_NAME})
add_executable(${app_} main.cpp)
target_link_libraries(${app_} clsocket)

Pre-build cmake stage passes fine, but the build fails:

[main] Building folder: clsocket-cmake
[build] Starting build
[proc] Executing command: /Users/me/brew/bin/cmake --build /Users/me/src/clsocket-cmake/build --config Debug --target all --
[build] [1/2  50% :: 0.057] Building CXX object CMakeFiles/test_clsocket_cmake.dir/main.o
[build] FAILED: CMakeFiles/test_clsocket_cmake.dir/main.o
[build] /usr/bin/clang++   -g -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -std=gnu++17 -MD -MT CMakeFiles/test_clsocket_cmake.dir/main.o -MF CMakeFiles/test_clsocket_cmake.dir/main.o.d -o CMakeFiles/test_clsocket_cmake.dir/main.o -c /Users/me/src/clsocket-cmake/main.cpp
[build] /Users/me/src/clsocket-cmake/main.cpp:1:10: fatal error: 'PassiveSocket.h' file not found
[build] #include <PassiveSocket.h>
[build]          ^~~~~~~~~~~~~~~~~
[build] 1 error generated.
[build] ninja: build stopped: subcommand failed.
[proc] The command: /Users/me/brew/bin/cmake --build /Users/me/src/clsocket-cmake/build --config Debug --target all -- exited with code: 1 and signal: null
[build] Build finished with exit code 1

virtual methods

most methods in the classes are virtual.
i don't see any obvious reason for this - and tend to remove the "virtual" keyword!
am i wrong?

Great Library! - Windows timing question ?

Hello Mark,
The clsocket library looks well structured and suited to handle many socket applications in one shot.
I like it a lot!
I also like the abundance of comments ! Fantastic !
Just one question:
In the CStatTimer class I see you don't QueryPerformanceFrequency for WIN32.
How do you get accurate time based counts without doing that ? Whats the secret ?
The way understand QueryPerformanceCounter just gets a count/tick...but you need to combine it with the Frequency to get a time based count ?
Thanks & Cheers

Include example covering error handling

Using a simple:

networkConnection->TranslateSocketError();
CSimpleSocket::CSocketError e = networkConnection->GetSocketError();
networkConnection->DescribeError(e);

Has seemed to error every time. Also, I've been getting -1 from networkConnection->Receive() and when checking the error using the above code, the error is CSimpleSocket::CSocketError::SocketSuccess.

CPassiveSocket::Listen() behaves different on Windows

On Windows,

    SETSOCKOPT(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&nReuse, sizeof(int32));
    SETSOCKOPT(m_socket, IPPROTO_TCP, IP_TOS, &nReuse, sizeof(int32));

is NOT executed, where especially setting SO_REUSEADDR leads to different behaviour,
when closing listening socket .. and trying to listen again within a few seconds.

same behaviour could be achieved, when always calling
CSimpleSocket::SetOptionReuseAddr()

always inside Listen() - as alternative, have it called from outside before calling Listen() - if desired.

The same issue also for IPPROTO_TCP / IP_TOS but this function is missing in CSimpleSocket - for now.

Install failing on visual studio 2017

The install is failing on visual studio 2017, on windows 7. I get the following error:

[1/2] Linking CXX shared library clsocket-CMAKE\clsocket.dll
FAILED: clsocket-CMAKE/clsocket.dll clsocket-CMAKE/clsocket.lib 
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=clsocket-CMAKE\CMakeFiles\clsocket.dir --manifests  -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1414~1.264\bin\Hostx86\x86\link.exe /nologo clsocket-CMAKE\CMakeFiles\clsocket.dir\src\SimpleSocket.obj clsocket-CMAKE\CMakeFiles\clsocket.dir\src\ActiveSocket.obj clsocket-CMAKE\CMakeFiles\clsocket.dir\src\PassiveSocket.obj  /out:clsocket-CMAKE\clsocket.dll /implib:clsocket-CMAKE\clsocket.lib /pdb:clsocket-CMAKE\clsocket.pdb /dll /version:4.0 /machine:X86 /debug /INCREMENTAL  Ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  && cd ."
RC Pass 1: command "rc /foclsocket-CMAKE\CMakeFiles\clsocket.dir/manifest.res clsocket-CMAKE\CMakeFiles\clsocket.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
Install failed.

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.