Simplified socket creation and handling
Donald Duvall
don.duvall at deduvall.com
Fri May 25 13:50:25 PDT 2012
On Wednesday, 23 May 2012 at 19:24:53 UTC, Jarl André wrote:
> On Wednesday, 23 May 2012 at 13:39:09 UTC, Jarl André wrote:
>> On Saturday, 19 May 2012 at 20:33:49 UTC, Nathan M. Swan wrote:
>>> On Friday, 18 May 2012 at 06:35:59 UTC, Jarl André wrote:
>>>> I am a Java developer who is tired of java.nio and similar
>>>> complex socket libraries.
>>>>
>>>> In Java you got QuickServer, the ultimate protocol creation
>>>> centered socket library. You don't have to write any
>>>> channels and readers and what not. You just instantiate a
>>>> server, configures the handlers (fill in classes that
>>>> extends a handler interface) and there you go.
>>>>
>>>> Shouldn't there exist a similar library in any programming
>>>> language? Not doing so is assuming that developers always
>>>> need control of the lower layers. Its not true. I care about
>>>> protocol. Not sockets.
>>>>
>>>> Is there any abstraction layers in phobos? Or is everything
>>>> just as complex as before?
>>>
>>> Check out arsd:
>>> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
>>>
>>> I used cgi.d to make my own server easily (compile with
>>> -version=embedded_httpd). If you want more lower-level
>>> control, try a ListeningConnectionManager. To see how it's
>>> used, look at the code starting on line #1926.
>>>
>>> It has some pitfalls (e.g. I can't find a good way to stop
>>> the server), but it is very nice in _easily_ starting up,
>>> with _zero_ config.
>>>
>>> NMS
>>
>> Thanks. It looks like a good option.
>>
>> As it turns out I am very interested in having complete
>> control of what type of service I am creating, so a library
>> limiting me in some ways are not an option. On the other hand,
>> I have investigated the listener example and have found out
>> that I needed to generalize it a bit. Make a few interfaces,
>> some implementations and my initial goal is to have end user
>> code look excactly like QuickServers in Java. Why? Because
>> sometimes you need simple command servers, lets say for
>> polling an email or checking hardware status on a server and
>> report it back, not worrying about blocking and async or
>> whatever about sockets.
>>
>> Another great advantage of making a "QuickServer" library is
>> that its inner content can be replaced in the future without
>> the end users knowing about. I have come far in the library
>> making, but need some help understanding std.socket:
>>
>> 1.a. What is SocketSet and why do I need to pass it to
>> Socket.select?
>> 1.b. I only want to accept new sockets and I think its too
>> much code for that
>>
>> Even if questions is stupid please comment/correct me.
>
> And here it comes:
>
> https://github.com/jarlah/d2-simple-socket-server
>
> This is my object oriented contribution to the problem.
>
> Based on closed/open principe, in that expansion is done by
> adding new classes and not modifying the existing code.
>
> Comments are appreciated.
Would it be possible for someone to write some documentation on
this socket server and make it windows compatible?
I am just learning D and coming from C# sockets this is much
different and I understand it completely. I would much appreciate
any help with understanding sockets in D and any pointers in the
right direction.
More information about the Digitalmars-d-learn
mailing list