Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2004-09-14 06:25:01


On Tue, Sep 14, 2004 at 01:06:29PM +0200, Carlo Wood wrote:
[...snip...]

That being said, I do have remark on the windows API level
that hooks into your page ;).

You write:

class socket {
  public:

    // ...

    template<typename functor_type>
    watch on_close(functor_type functor) {
      return global_multiplexor.on_file_readable(socket_fd,
        if_then(bind(is_eof, this), functor));
    }

    // ...
  private:

    static bool is_eof(socket &);

    int socket_fd;

    // ...
};

One of the problems that can't seem to put a finger on is the fact that
windows uses different types for file handles and for sockets.

How can I related HANDLE and SOCKET? And are there any other handle
types that I am not aware of? Can SOCKET be casted to a HANDLE just
like that? Or even converted without cast?

On http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/readfileex.asp
I read the following:

    BOOL ReadFileEx(
      HANDLE hFile,
      LPVOID lpBuffer,
      DWORD nNumberOfBytesToRead,
      LPOVERLAPPED lpOverlapped,
      LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    );

    Parameters

    hFile

      [...]

      This parameter can be any handle opened with the FILE_FLAG_OVERLAPPED
      flag by the CreateFile function, or a socket handle returned by the
      socket() or accept() function.

Note that CreateFile indeed retuns a HANDLE, but socket() and accept() return
a SOCKET type?!

Does this mean that a SOCKET == HANDLE *and* that they made it impossible for
themselfs to ever change that in the future? And how about SOCKET types that
are not returned by socket() or accept() (or are those the only windows
functions to ever return create a SOCKET type?).

-- 
Carlo Wood <carlo_at_[hidden]>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk