Windows Compilation problem

Horacio Sanson hsanson at gmail.com
Thu Jun 26 04:09:35 CEST 2008


Ok I think I solved my problem but want to make sure it is the correct
way to do this.

I keep all my code the same except for the calls to ev_io_set().
Instead of passing the socket descriptor as returned by socket() or
WSASocket() I convert if first to handle and then pass the handle to
ev_io_set...  the relevant code looks like:

ev_io_set (&client->read_watcher, _open_osfhandle(client->socketfd,
0), EV_READ | EV_ERROR);

This works as my client now connects and transmits data to the server
(Linux) but is a little ugly.

better ways to do this are appreciated...

Horacio

On Thu, Jun 26, 2008 at 10:28 AM, Horacio Sanson <hsanson at gmail.com> wrote:
> On Fri, Jun 6, 2008 at 9:35 AM, Chris Hulbert <chris.hulbert at gmail.com> wrote:
>> FYI, i just had the same problem.
>> To convert from a socket to a file descriptor, you'll need to use this function:
>>
>>  // for win32: convert from socket to file descriptor
>>  // // http://msdn.microsoft.com/en-us/library/bdts1c9x(VS.71).aspx
>>  int fd = _open_osfhandle(socket,0);
>>
>
> I just encounter this same error but I am unable to solve it. My
> program can create a socket() and actually connect to the server using
> connect() but when I start the libev default loop an assertion ocurrs
> when it calls _get_osfhandle() on line 716 of ev.c file.
>
> How exactly am I supposed to use the _open_osfhandle() method as you
> mention here?? If I use this method on the socket I get from the
> socket() method then all subsequent calls on the socket (i.e. connect,
> bind, listen) would return WSAENOTSOCK error.
>
> Shall I replace all instances of _get_osfhandle() with a call to
> _open_sofhandle()??  or am I missing something else??
>
> regards
> Horacio
>
>> On Thu, Jun 5, 2008 at 6:23 PM, Marc Lehmann <schmorp at schmorp.de> wrote:
>>> On Wed, Jun 04, 2008 at 04:29:46PM -0700, Matt Tolton <matt at tolton.com> wrote:
>>>> Any pointers here?  The fd that I'm using is a socket obtained from
>>>> the winsock socket() call.  Here is the code used to initialize it:
>>>
>>> That doesn't work - the libev API requires file descriptors on all
>>> platforms.  What you pass in is a native opertaing system handle that is
>>> not a file descriptor.
>>>
>>
>> _______________________________________________
>> libev mailing list
>> libev at lists.schmorp.de
>> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>>
>



More information about the libev mailing list