[erlang-questions] Low Level Socket Example

Serge Aleynikov saleyn@REDACTED
Tue Aug 12 22:46:00 CEST 2008


If you are interested in learning the details of network protocols, 
Erlang could be your friend for the task as a rapid prototyping 
framework.  You have to be aware though that a TCP stack in Erlang will 
not deliver the same performance as the kernel-level stack 
implementation.  However it is doable as a proof of concept.

The network driver that comes with Erlang is not suited for this task, 
as it serves as a bridge between TCP/SCTP/UDP protocols and the 
emulator.  So if you really have interest in accessing raw sockets, 
you'd need to write a driver in C/C++  to marshal raw packets between 
user-level POSIX API and an Erlang process.

Serge

Marc Eisenbarth wrote:
>> Why can't you use gen_tcp? Do you really need to implement OS level APIs
>> in
>> Erlang? Erlang really isn't the right language for raw socket
>> manipulation.
>> Try out C.
> 
> gen_tcp will do the entire TCP session setup for me, so it's not appropriate for my task. Just because C might be better for this task, doesn't mean it's better for the rest of my program. In fact, there's are at least 2 examples of projects that implement network stacks in Erlang, so at least a few people out there that would disagree with you and instead agree that there is some merit in using Erlang :)




More information about the erlang-questions mailing list