[erlang-questions] Does ei_connect on windows work?

Andrew Thompson andrew@REDACTED
Fri Jun 12 00:32:57 CEST 2009

On Wed, Jun 10, 2009 at 06:32:57PM -0400, Andrew Thompson wrote:
> Hi,
> I've been toying with porting my ei/ei_connect based FreeSWITCH (an open
> source VOIP soft-switch, see freeswitch.org) module to windows because
> I've had a couple requests for it. I figured it'd be pretty easy once
> I fixed all the networking code to be winsock compliant. However, even
> once I fixed all that (and some other cool snags introduced by visual
> C++) I'm now having cool errors when I call ei_accept_tmo. I looked at
> the source for the ei files and I'm unclear as to how well supported
> the ei_connect stuff is supported on windows, it uses int for sockets
> instead of the win32 SOCKET type, for example and I noticed that
> initWinSock() tries to initialize winsock 1.1 (the one that debuted with
> windows 95) instead winsock 2 (which is available for 95, NT4 and up).
> Can anyone give me an idea as to if trying to write a C node to run
> under windows is even possible with the current status of ei_connnect.

So I did some more digging and after managing to compile ei in debug
mode on windows, I think I've found the problem (or at least one of
them). I'm linking ei.lib into a .dll that is loaded as a FreeSWITCH
module, but erl_errno is defined as a thread-local variable which is
causing stuff to explode when it's accessed. If I recompile without the
declspec stuff I can actually load the module and ping the C node.

I'll continue trying to make it work with the default compile flags
(apparently TLSAlloc is what I should be using) but I figured I'd put
this here for anyone else who ever runs into this.


More information about the erlang-questions mailing list