Even if this seems quite easy. There is also some other differences and problems with winsock2.h (Checkout the StackOverflow question.)
Yet this can be a solution still.
Possible Solution 2
Use Cygwin as compiler.
Cygwin has the headers such that <sys/socket.h> and other Unix headers that don't simply exist in Windows. As long as we don't use fork() which is really buggy as I heard of it.
fork() could have been used for some async jobs that are actually quite important so I don't know if this is the right answer to this problem.
So, yes. I can't seem to find any possible cross-platform library's in C such that we can easily listen to a port and send simple TCP or UDP packets.
This problem happens because, Unix uses <sys/socket.h> while Windows uses for sockets. There a couple of solutions to this tho.
Possible Solution 1
https://stackoverflow.com/a/4642169/10768104
Compile both for Unix and Windows independently
`#ifdef WIN32
include
else
include <sys/socket.h>
endif `
Even if this seems quite easy. There is also some other differences and problems with winsock2.h (Checkout the StackOverflow question.) Yet this can be a solution still.
Possible Solution 2
Use Cygwin as compiler. Cygwin has the headers such that <sys/socket.h> and other Unix headers that don't simply exist in Windows. As long as we don't use fork() which is really buggy as I heard of it. fork() could have been used for some async jobs that are actually quite important so I don't know if this is the right answer to this problem.
Possible Solution 3
No Cross-platform for us. :(