<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi<div><br></div><div>I've written a NIF that takes data from an external device driver, converts it to a term (a tuple) and uses enif_send (from a thread created by the nif) to a specific Erlang process.</div><div><br></div><div>Unfortunately on some deployments we have been forced to disable SMP in the Linux kernel and BEAM due to a third-party driver issue. In these cases what I have done is used enif_system_info in the NIF, and if SMP is disabled I will send the message via a unix domain socket (I have a driver for that) instead of enif_send.</div><div><br></div><div>On the Erlang side the UDS is opened, and I use erlang:open_port to pass the unix domain socket to the event loop. What is nice here is that I can use the same Erlang and C code for both SMP enabled and disabled systems. So the Erlang process would get an Erlang message like:</div><div><br></div><div>{driver_result,Integer,Integer} - If SMP is enabled</div><div><br></div><div>Or: </div><div><br></div><div><div>{#Port<0.647>,{data,SomeBinary}} - If SMP is disabled</div></div><div><br></div><div>What I would like to do is see if I can send the message as an Erlang term to the unix domain socket using something like term_to_binary in the NIF (I would prefer that instead of sending raw binary to Erlang with enif_send).</div><div><br></div><div>Is that possible?</div><div><br></div><div>Thanks</div><div><br></div><div>Matt</div> </div></body>
</html>