Class: TCPSocket
- Inherits:
-
IPSocket
- Object
- IO
- BasicSocket
- IPSocket
- TCPSocket
- Defined in:
- lib/rubysl/socket.rb
Direct Known Subclasses
Constant Summary collapse
- FFI =
Rubinius::FFI
Class Method Summary collapse
Instance Method Summary collapse
- #from_descriptor(descriptor) ⇒ Object
-
#initialize(host, port, local_host = nil, local_service = nil) ⇒ TCPSocket
constructor
A new instance of TCPSocket.
- #send(bytes_to_read, flags, to = nil) ⇒ Object
Methods inherited from IPSocket
#addr, getaddress, #peeraddr, #recvfrom, #recvfrom_nonblock
Methods inherited from BasicSocket
#close_read, #close_write, #do_not_reverse_lookup, do_not_reverse_lookup, #do_not_reverse_lookup=, do_not_reverse_lookup=, for_fd, from_descriptor, #getpeername, #getsockname, #getsockopt, #recv, #recv_nonblock, #recvfrom, #setsockopt, #shutdown
Constructor Details
#initialize(host, port, local_host = nil, local_service = nil) ⇒ TCPSocket
Returns a new instance of TCPSocket.
1375 1376 1377 1378 1379 1380 1381 |
# File 'lib/rubysl/socket.rb', line 1375 def initialize(host, port, local_host=nil, local_service=nil) @no_reverse_lookup = self.class.do_not_reverse_lookup @host = host @port = port tcp_setup @host, @port, local_host, local_service end |
Class Method Details
.gethostbyname(hostname) ⇒ Object
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 |
# File 'lib/rubysl/socket.rb', line 1351 def self.gethostbyname(hostname) addrinfos = Socket.getaddrinfo(hostname, nil) hostname = addrinfos.first[2] family = addrinfos.first[4] addresses = [] alternatives = [] addrinfos.each do |a| alternatives << a[2] unless a[2] == hostname addresses << a[3] if a[4] == family end [hostname, alternatives.uniq, family] + addresses.uniq end |
Instance Method Details
#from_descriptor(descriptor) ⇒ Object
1488 1489 1490 1491 1492 |
# File 'lib/rubysl/socket.rb', line 1488 def from_descriptor(descriptor) IO.setup self, descriptor, nil, true self end |
#send(bytes_to_read, flags, to = nil) ⇒ Object
1370 1371 1372 |
# File 'lib/rubysl/socket.rb', line 1370 def send(bytes_to_read, flags, to = nil) super(bytes_to_read, flags) end |