Re: Using libev with Windows sockets

2016-05-13 Thread Marc Lehmann
On Wed, May 11, 2016 at 10:22:10PM +, Eric Fowler 
 wrote:
> I have inherited a pretty large Linux-based server project and am tasked with 
> porting it to Windows. It is heavily dependent upon libev and libeio.

Both libeio and libev work fine in a win32 environment (well, in some
envgironments, there are so many incompatible ones - I would try mingw,
where it is known to work), as well as in cygwin, which would be a an eaiser
choice to port uinix software to windows.

(And Microsoft is officially workign on linux emulation already, might
want to go for that once it's stable, who knows :).

> (1)- I have noticed that libev uses socket descriptors as array indexes 
> in several places. This is fine on Linux because the socket descriptors are 
> always small (typical values range from 4 to 8 for small numbers of sockets). 
> However, Windows socket handles have integer values starting at nearly 200, 
> with the high value undefined. This would seem to make them useless as array 
> indices. Am I justified in my concern or is there something about Winsock or 
> libev that I am not seeing?

You have to convert the socket handles to fd's. as described in the manual
(have you read the WIN32 PLATFORM... chapter?). How you do that is up to
you, most commonly (and supported out of the box) is using the Microsoft
libc.

> (2)- Our code is getting a Windows socket descriptor and passing it down 
> into libev, where it comes a-cropper on an EV_FD_TO_WIN32_HANDLE() macro in 
> ev.c!fd_reify() [line 2084]. I am not surprised that the macro choked; it is 
> trying to convert a windows socket descriptor to a windows socket descriptor, 
> which should not be expected to work. The bigger question is, 'What am I 
> doing wrong?' Should I not expect the libev code to *ever* see a windows 
> socket handle? There must be some design strategy WRT windows handles here, 
> but I am not seeing it. The code is within an #ifdef block that expects 
> Windows ... does this mea

You need to use a file descriptor, just as on a POSIX system.

> it does not expect to see windows handles? Is there a simple way to fish a 
> BSD style socket descriptor out of a windows socket handle?

That depends on your environment - if you use the microsoft c library,
the easy way would be open_osfhandle. You really need to read the ev
manual on win32 though, to understand how to work around the usual windows
limitations.

-- 
The choice of a   Deliantra, the free code+content MORPG
  -==- _GNU_  http://www.deliantra.net
  ==-- _   generation
  ---==---(_)__  __   __  Marc Lehmann
  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Using libev with Windows sockets

2016-05-11 Thread Eric Fowler
I have inherited a pretty large Linux-based server project and am tasked with 
porting it to Windows. It is heavily dependent upon libev and libeio.


(1)- I have noticed that libev uses socket descriptors as array indexes in 
several places. This is fine on Linux because the socket descriptors are always 
small (typical values range from 4 to 8 for small numbers of sockets). However, 
Windows socket handles have integer values starting at nearly 200, with the 
high value undefined. This would seem to make them useless as array indices. Am 
I justified in my concern or is there something about Winsock or libev that I 
am not seeing?

(2)- Our code is getting a Windows socket descriptor and passing it down 
into libev, where it comes a-cropper on an EV_FD_TO_WIN32_HANDLE() macro in 
ev.c!fd_reify() [line 2084]. I am not surprised that the macro choked; it is 
trying to convert a windows socket descriptor to a windows socket descriptor, 
which should not be expected to work. The bigger question is, 'What am I doing 
wrong?' Should I not expect the libev code to *ever* see a windows socket 
handle? There must be some design strategy WRT windows handles here, but I am 
not seeing it. The code is within an #ifdef block that expects Windows ... does 
this mean it does not expect to see windows handles? Is there a simple way to 
fish a BSD style socket descriptor out of a windows socket handle?

Thanks very much

WW


The information in this email, and any attachments, may contain confidential 
information and is intended solely for the attention and use of the named 
addressee(s). It must not be disclosed to any person(s) without authorization. 
If you are not the intended recipient, or a person responsible for delivering 
it to the intended recipient, you are not authorized to, and must not, 
disclose, copy, distribute, or retain this message or any part of it. If you 
have received this communication in error, please notify me immediately.
___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev