Skip to content

Commit

Permalink
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -688,6 +688,17 @@ public int getppid() {

}

@CoreMethod(names = "send", isModuleFunction = true, required = 4, lowerFixnum = {1, 3, 4}, unsafe = UnsafeGroup.IO)
public abstract static class SendNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubyPointer(buffer)")
public int send(int descriptor, DynamicObject buffer, int bytes, int flags) {
return nativeSockets().send(descriptor, Layouts.POINTER.getPointer(buffer), bytes, flags);
}

}

@CoreMethod(names = "symlink", isModuleFunction = true, required = 2, unsafe = UnsafeGroup.IO)
public abstract static class SymlinkNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -85,6 +85,11 @@ public int connect(int socket, Pointer address, int address_len) {
throw new UnsupportedOperationException();
}

@Override
public int send(int sockfd, Pointer buf, int len, int flags) {
throw new UnsupportedOperationException();
}

@Override
public int shutdown(int socket, int how) {
throw new UnsupportedOperationException();
Original file line number Diff line number Diff line change
@@ -119,6 +119,11 @@ public interface Sockets {

int connect(int socket, Pointer address, int address_len);

/**
* int send(int sockfd, Pointer buf, int len, int flags);
*/
int send(int sockfd, Pointer buf, int len, int flags);

/**
* int shutdown(int sockfd, int how);
*/

1 comment on commit 56ae861

@bjfish
Copy link
Contributor

@bjfish bjfish commented on 56ae861 Oct 4, 2016

Choose a reason for hiding this comment

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

Tested this with netcat: nc -l 4444

require "socket"
s = TCPSocket.new('127.0.0.1',4444)
s.send('hello\000', 0) 

Please sign in to comment.