nxdk icon indicating copy to clipboard operation
nxdk copied to clipboard

Winsock implementation

Open JayFoxRox opened this issue 4 years ago • 2 comments

(I'm very sure we discussed this in the past, but I'm unable to find anything when searching for "winsock" on this repository; please close if I missed an existing issue)

I had started a rather dummy ws2_32.lib implementation about a year ago and I believe @thrimbor had also worked on something in that direction? A real implementation would be nice, but a partially working dummy is also fine with me, just to get the ball rolling.

Specifically, my winsock was exclusively meant for enet, and it can be found here: https://github.com/JayFoxRox/nxdk/pull/84. At the time of writing, the latest version is in https://github.com/JayFoxRox/nxdk/commit/f3dd88898180e6e59d6f42956c346615e335208e. I don't think I ever really tested it, so it's probably non-functional.

It would be nice if someone could find a suitable implementation or clean up the mess from my commit. Consider my code in that commit to be in public domain (feel free to steal code or relicense as whatever). More formally: I also license that code under CC0.

JayFoxRox avatar Apr 11 '21 18:04 JayFoxRox

I would like this as well as I would like to use enet (fork from https://github.com/cgutman/enet/tree/moonlight) in a project I'm attempting. I had a look at your previous attempt, but for now it's a bit above my head to get to a working state.

I was wondering if it might be easier to compile enet as UNIX instead of WIN32, and then re-implement the required parts from the Linux source. It'd still be above my head, but maybe it's easier since it's open source.

ReenigneArcher avatar Oct 31 '24 03:10 ReenigneArcher

The use of WSASendMsg in that fork is probably problematic. It is used at least in https://github.com/cgutman/enet/commit/e790647a577fb1402b5a25a479a03d4045f5aa44#diff-14d02ab34000ddb786c1258055d552d6b6613c608e2e515096fdc8abe26e9e90R474 It's rather advanced and I'm not sure if lwip (or my code) supports it - I doubt it. It's mostly relevant for multiple network addresses, application specific routing (like tracing) or IPv6. You could probably implement some WSASendMsg which just ignores some fields (for now).

Aside from that, the UNIX and WIN32 code-path should only differ slightly. Typically WIN32 networking only adds winsock specific init and cleanup and some utility functions related to timing or buffer allocations - all of which nxdk probably already supports.

I don't remember, but my winsock implementation probably also merely stubs the init/cleanup and hooks up the Winsock BSD-style socket API to the lwip BSD-style socket interface.

JayFoxRox avatar Oct 31 '24 10:10 JayFoxRox