www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos sockets

reply Martin Hess <martinhess mac.com> writes:
I'm trying to figure which socket API to use in Phobos. There appears 
to be 3 choices for linux:

1) A general version: std.socket

2) A linux version: std.c.linux.socket
	- this one gets a version assert on X86_64

3) The last isn't really a socket class but it has the socket calls: 
std.c.unix.unix. It is used by version #1 above.

Version #2 redeclares the c socket api that is declared in #3

Are all 3 versions considered public?

Is #2 really just for X86, or should it also work with any Unix/BSD 
socket implementation?

Which one is best tested? Which of course leads to the question is 
there any kind of test suite for Phobos?
Nov 16 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Martin Hess wrote:
 I'm trying to figure which socket API to use in Phobos. There appears to 
 be 3 choices for linux:
 
 1) A general version: std.socket
 
 2) A linux version: std.c.linux.socket
     - this one gets a version assert on X86_64
 
 3) The last isn't really a socket class but it has the socket calls: 
 std.c.unix.unix. It is used by version #1 above.
 
 Version #2 redeclares the c socket api that is declared in #3
 
 Are all 3 versions considered public?
 
 Is #2 really just for X86, or should it also work with any Unix/BSD 
 socket implementation?
 
 Which one is best tested? Which of course leads to the question is there 
 any kind of test suite for Phobos?

All the std.c.* packages are just ports of the C header files to let you link with native C standard library functions. I've never used sockets in D, so I don't know for sure, but I'd guess 1) is the one you should be using since it was made specifically for D. --bb
Nov 16 2007
parent "Janice Caron" <caron800 googlemail.com> writes:
I've used std.sockets. It was actually very easy to use. I would
definitely recommend that.

If you already understand the C API, then learning the D API is a
piece of cake, and the end result is /much/ nicer code. I mean - it
uses classes for Walter's sake! C only uses functions and so feels
very old and clunky by comparison.

There is a fourth option. Tango also has sockets. I've got absolutely
no idea how to use them, but they're definitely there. I can't
recommend that, because I'm a Phobos-lover, and wouldn't dream of
recommending Tango until the two become compatible, but I can't deny
the option exists.
Nov 17 2007