sendmsg_nonblock

basicsocket.sendmsg_nonblock(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent Instance Public methods #sendmsg_nonblock sends a message using sendmsg(2) system call in non-blocking manner. It is similar to #sendmsg but the non-blocking flag is set before the system call and it doesn't retry the system call.

sendmsg

basicsocket.sendmsg(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent Instance Public methods sendmsg sends a message using sendmsg(2) system call in blocking manner. mesg is a string to send. flags is bitwise OR of MSG_* constants such as Socket::MSG_OOB. dest_sockaddr is a destination socket address for connection-less socket. It should be a sockaddr such as a result of Socket.sockaddr_in. An Addrinfo object can be used too. controls is a list of ancillary data. T

send

basicsocket.send(mesg, flags [, dest_sockaddr]) => numbytes_sent Instance Public methods send mesg via basicsocket. mesg should be a string. flags should be a bitwise OR of Socket::MSG_* constants. dest_sockaddr should be a packed sockaddr string or an addrinfo. TCPSocket.open("localhost", 80) {|s| s.send "GET / HTTP/1.0\r\n\r\n", 0 p s.read }

remote_address

bsock.remote_address => addrinfo Instance Public methods Returns an Addrinfo object for remote address obtained by getpeername. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.remote_address #=> #<Addrinfo: 221.186.184.68:80 TCP> } TCPServer.open("127.0.0.1", 1728) {|serv| c = TCPSocket.new("127.0.0.1", 1728) s = serv.accept p s.remote_address #=> #<Addrinfo: 127.0.0.1:36504 TCP> }

recvmsg_nonblock

basicsocket.recvmsg_nonblock(maxdatalen=nil, flags=0, maxcontrollen=nil, opts={}) => [data, sender_addrinfo, rflags, *controls] Instance Public methods recvmsg receives a message using recvmsg(2) system call in non-blocking manner. It is similar to #recvmsg but non-blocking flag is set before the system call and it doesn't retry the system call.

recvmsg

basicsocket.recvmsg(maxmesglen=nil, flags=0, maxcontrollen=nil, opts={}) => [mesg, sender_addrinfo, rflags, *controls] Instance Public methods recvmsg receives a message using recvmsg(2) system call in blocking manner. maxmesglen is the maximum length of mesg to receive. flags is bitwise OR of MSG_* constants such as Socket::MSG_PEEK. maxcontrollen is the maximum length of controls (ancillary data) to receive. opts is option hash. Currently :scm_rights=>bool is the only opti

recv_nonblock

basicsocket.recv_nonblock(maxlen) => mesgbasicsocket.recv_nonblock(maxlen, flags) => mesg Instance Public methods Receives up to maxlen bytes from socket using recvfrom(2) after O_NONBLOCK is set for the underlying file descriptor. flags is zero or more of the MSG_ options. The result, mesg, is the data received. When recvfrom(2) returns 0, #recv_nonblock returns an empty string as data. The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc. Parameters max

recv

basicsocket.recv(maxlen) => mesgbasicsocket.recv(maxlen, flags) => mesg Instance Public methods Receives a message. maxlen is the maximum number of bytes to receive. flags should be a bitwise OR of Socket::MSG_* constants. UNIXSocket.pair {|s1, s2| s1.puts "Hello World" p s2.recv(4) #=> "Hell" p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo" p s2.recv(4) #=> "o Wo" p s2.recv(10) #=> "rld\n" }

local_address

bsock.local_address => addrinfo Instance Public methods Returns an Addrinfo object for local address obtained by getsockname. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.local_address #=> #<Addrinfo: 192.168.0.129:36873 TCP> } TCPServer.open("127.0.0.1", 1512) {|serv| p serv.local_address #=> #<Addrinfo: 127.0.0.1:1512 TCP> }

getsockopt

getsockopt(level, optname) => socketoption Instance Public methods Gets a socket option. These are protocol and system specific, see your local system documentation for details. The option is returned as a Socket::Option object. Parameters level is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. optname is an integer, usually one of the SO_ constants, suc