Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Add socket streams. #3

Merged
merged 6 commits into from
Jun 18, 2016
Merged

Add socket streams. #3

merged 6 commits into from
Jun 18, 2016

Conversation

tmccombs
Copy link
Contributor

No description provided.

assert(!sock.isOpen);
ubyte[1] buff;
assert(pair[0].receive(buff) == Socket.ERROR);
assert(errno == EBADF);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referencing EBADF is failing the Windows build.

@jasonwhite
Copy link
Owner

jasonwhite commented Jun 15, 2016

I'd like to merge this, but the two new files are missing the copyright header. I'm a bit inexperienced with this part of open source, but I think the best approach is to use the same copyright header as the other files and list yourself as the sole author (in the Authors: section). Let me know what you think.


sock.write(data);
assert(other.receive(buff) == Socket.ERROR);
assert(errno == EAGAIN);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows build is failing here now.

@jasonwhite jasonwhite merged commit 3bbe439 into jasonwhite:master Jun 18, 2016
@MartinNowak
Copy link

Using std.socket as a basis for a new I/O library is bad idea, b/c you inherit all the bad parts (e.g. usage of GC allocated class).
Why not simply write your own socket implementation based on simple file descriptors. There isn't much complexity buried in std.socket.

@jasonwhite
Copy link
Owner

I agree. This needs to be rewritten to not use std.socket. I merged this because it can be useful in the meantime and I'm not too concerned about breaking things later. I haven't had a need for sockets yet, but when I do I'll probably end up rewriting this.

@tmccombs tmccombs deleted the socketstream branch July 10, 2016 04:49
@tmccombs
Copy link
Contributor Author

There isn't much complexity buried in std.socket.
It does abstract differences between posix sockets and winsockets and does quite a bit around sockaddr. A thin wrapper around connect for example would require the user to allocate memory for the appropriate sockaddr type, initialize it, and cast a pointer to it to a sockaddr*.

I agree that std.socket should be replaced with something that doesn't depend use GC allocated objects, but I don't think that will be a simple task. I would be happy to help work on it though.

@MartinNowak
Copy link

Taking a look at the Handle based io.file.stream would be a good starting point. We also established a few principles like using scattered readv/writev.
I guess the more difficult part is to replace InternetAddress, but that could be done as a second step.

@MartinNowak
Copy link

I merged this because it can be useful in the meantime and I'm not too concerned about breaking things later.

Which is OK for a 0.0.8 version, but stability is key for adoption ;). I'd really like to help out more, b/c this library looks a lot like what I want for std.io, but I'm too busy w/ the compiler and related things.
Maybe we can attract some other contributors? There are a handful of existing D socket implementations out there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants