summaryrefslogtreecommitdiff
path: root/ext/socket
AgeCommit message (Collapse)Author
2018-01-23getaddrinfo.c: ai_errlistnobu
* ext/socket/getaddrinfo.c (ai_errlist): used only if gai_strerror is missing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15raddrinfo.c: fix parse_numeric_portnobu
* ext/socket/raddrinfo.c (parse_numeric_port): necessary regardless of GETADDRINFO_EMU. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22ifaddr.c: get_ifaddrsnobu
* ext/socket/ifaddr.c (get_ifaddrs): extract ifaddrs from Socket::Ifaddr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04ifaddr.c: fix memsizenobu
* ext/socket/ifaddr.c (ifaddr_memsize): do not count the whole rb_ifaddr_t array for each elements. the header size is included in the first element for the time being. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03ifaddr.c: unused membernobu
* ext/socket/ifaddr.c (struct rb_ifaddr_tag): removed set but unused member root. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07socket.c,tcpsocket.c: improve deprecation noticesstomar
* ext/socket/socket.c: [DOC] fix grammar in deprecation notices. * ext/socket/tcpsocket.c: [DOC] ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07ext/socket/ifaddr.c: [DOC] fix typostomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27socket: fix BasicSocket#*_nonblock buffering bugs from r58400normal
IO#read_nonblock and IO#write_nonblock take into account buffered data, so the Linux-only BasicSocket#read_nonblock and BasicSocket#write_nonblock methods must, too. This bug was only introduced in r58400 ("socket: avoid fcntl for read/write_nonblock on Linux") and does not affect any stable release. * ext/socket/basicsocket.c (rsock_init_basicsocket): * ext/socket/init.c (rsock_s_recvfrom_nonblock): * ext/socket/init.c (rsock_init_socket_init): * ext/socket/lib/socket.rb (def read_nonblock): * ext/socket/lib/socket.rb (def write_nonblock): * ext/socket/rubysocket.h (static inline void rsock_maybe_wait_fd): * test/socket/test_basicsocket.rb (def test_read_write_nonblock): [Feature #13362] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Fixed misspelling words.hsbt
These are detected by https://github.com/client9/misspell git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Add missing `buf` parameter to `recv_nonblock` doc [ci skip]nobu
[Fix GH-1725] From: yuuji.yaginuma <yuuji.yaginuma@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21reference Socket.getaddrinfo to Addrinfo.getaddrinfo.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21deprecate TCPSocket.gethostbyname.akr
TCPSocket.gethostbyname has problems similar to Socket.gethostbyname. An example of the problem which only the address family of the first address is returned: ``` pp TCPSocket.gethostbyname("www.wide.ad.jp") #=> ["www.wide.ad.jp", [], 10, "2001:200:dff:fff1:216:3eff:fe4b:651c", "203.178.137.58"] ``` The address family of the first address, AF_INET6 (10), is returned but the address family of the second address, AF_INET, is not returned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Describe recommended-methods.akr
Addrinfo.getaddrinfo is recommended instead of Socket.gethostbyname. Addrinfo#getnameinfo is recommended instead of Socket.gethostbyaddr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Deprecation document for gethostbyname,gethostbyaddr.akr
[Feature #13097] I confirmed current ruby (Ruby 2.4 and trunk) uses gethostbyname() and gethostbyaddr(). Socket.gethostbyname uses getaddrinfo() and gethostbyname(). Socket.gethostbyaddr uses gethostbyaddr(). Socket.gethostbyname uses gethostbyname() to obtain alias hostnames. RFC 3493 defines getaddrinfo()/getnameinfo() and describes the problems of gethostbyname()/gethostbyaddr(). The problems are difficult protocol handling and thread-unsafety. Since Ruby has GVL, the thread-unsafety doesn't cause wrong result. But it may block other threads until finishing DNS query. Socket.gethostbyname has the protocol handling problem. It returns only one address family: ``` % ruby -rpp -rsocket -e 'pp Socket.gethostbyname("www.wide.ad.jp")' ["www.wide.ad.jp", [], 10, " \x01\x02\x00\r\xFF\xFF\xF1\x02\x16>\xFF\xFEKe\x1C", "\xCB\xB2\x89:"] ``` www.wide.ad.jp has one IPv6 address and one IPv4 address. But Socket.gethostbyname returns only one address family, 10 (AF_INET6), which is the address family of the first address. Also, Socket.gethostbyname and Socket.gethostbyaddr uses 4-bytes binary IPv4 address and 16-bytes binary IPv6 address. This is not usual in other socket API in Ruby. (Most socket API uses binary sockaddr string or Addrinfo object) I think Socket.gethostbyname and Socket.gethostbyaddr are too far from recommendable API. So, I added deprecation description for documents for them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21add example for Socket.gethostbyaddr.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-11socket.c: null byte at Socket.getnameinfonobu
* ext/socket/socket.c (sock_s_getnameinfo): check null byte. patched by tommy (Masahiro Tomita) in [ruby-dev:50286]. [Bug #13994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-31Add Socket::Ifaddr.vhid on supported platforms [Feature #13803]naruse
patched by Alan Somers git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-25socket: system getaddrinfo on Windowsnobu
* ext/socket/extconf.rb: use system getaddrinfo, getnameinfo, and freeaddrinfo on Windows if they are provided. they conflict with addrinfo.h and cannot compile. conftest.exe linked against msvcr90.dll segfaults when invoked in extconf.rb for unknown reason, and failed to check them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-08separate constdefs.c and constdefs.hnobu
* ext/socket/depend: separate constdefs.c and constdefs.h so that only one process will run when parallel building. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-19socket: avoid fcntl for read/write_nonblock on Linuxnormal
On platforms where MSG_DONTWAIT works reliably on all sockets (so far, I know of Linux), we can avoid fcntl syscalls and implement IO#write_nonblock and IO#read_nonblock in terms of the socket-specific send and recv family of syscalls. This avoids side effects on the socket, and also encourages generic code to be written in cases where IO wrappers like OpenSSL::SSL::SSLSocket are used. Perhaps in the future, side-effect-free non-blocking I/O can be standard on all files and OSes: https://cr.yp.to/unix/nonblock.html * ext/socket/lib/socket.rb (read_nonblock, write_nonblock): Linux-specific wrapper without side effects [ruby-core:80780] [Feature #13362] * test/socket/test_basicsocket.rb (test_read_write_nonblock): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14IPSocket#inspectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-11Socket.udp_server_sockets: use symbol procnormal
Symbol proc is shorter human and machine code; and also avoids needing to name variables. * ext/socket/lib/socket.rb (Socket.udp_server_sockets): use symbol proc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09Get rid of inifinity retry loop in Socket.udp_server_socketsusa
* ext/socket/lib/socket.rb (Socket.udp_server_sockets): remove duplicated addresses before passing it to ip_sockets_port0 because it causes Errno::EADDRINUSE and retry forever. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-08basicsocket.c: proper system call namenobu
* ext/socket/basicsocket.c (rsock_bsock_send): show proper system call name in the exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22ruby tool/update-deps --fixshyouhei
Onigumo 6 (r57045) introduced new onigumo.h header file, which is required from quite much everywhere. This commit adds necessary dependencies. Note: ruby/oniguruma.h now includes onigumo.h, ruby/io.h includes oniguruma.h, ruby/encoding.h also includes oniguruma.h, and internal.h includes encoding.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09ext/socket/raddrinfo.c (addrinfo_mark): avoid needless branchnormal
gc.c (gc_mark_children, case T_DATA) does not use the dmark function pointer if DATA_PTR is NULL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27ext/socket/extconf.rb: fix a typonobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23Revert r57690 except for read_nonblocknobu
https://github.com/ruby/ruby/pull/1527#issuecomment-281867551 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] mark up literalsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] keyword argument _exception_nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23socket.rb: [DOC] fix nonblock methodsnobu
* ext/socket/lib/socket.rb (BasicSocket#recv_nonblock): fix exception class and symbol. * ext/socket/lib/socket.rb (BasicSocket#recvmsg_nonblock): ditto. * ext/socket/lib/socket.rb (Socket#recvfrom_nonblock): fix the method name. * ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): both. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] {read,write}_nonblock with exception: falsenobu
Update docs to reflect EOF behavior change of read_nonblock and write_nonblock when using `exception: false`. [Fix GH-1527] Author: Russell Davis <russell-stripe@users.noreply.github.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-16basicsocket (rsock_bsock_send): do not truncate return valuenormal
send(2) and sendto(2) syscalls return `ssize_t', use the proper type and macro for converting to a Numeric VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-21socket: use symbol proc for IO#close loopsnormal
Made possible by r56795, this reduces human and byte code size. * ext/socket/lib/socket.rb (self.ip_sockets_port0, self.tcp_server_sockets_port0, self.tcp_server_sockets, self.udp_server_sockets): use symbol proc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-15socket.rb: remove closed checksnobu
* ext/socket/lib/socket.rb: remove unnecessary closed checks, close on closed socket no longer raises an exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-14socket.rb: kwargsnobu
* ext/socket/lib/socket.rb (connect_{from,to}, connect): let use keyword arguments. * ext/socket/lib/socket.rb (Socket.tcp): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-27socket: fix rdoc of UDPSocket#recvfrom_nonblockrhe
* ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): [DOC] Remove a false statement "If _maxlen_ is omitted, its default value is 65536." maxlen, the first parameter, cannot be omitted as the method signature indicates. This hasn't changed ever since it was first implemented. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05* ext/socket/*.c: Add proper require for example to work.hsbt
[fix GH-1378][ci skip] Patch by @schneems git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-24fid typos [ci skip]nobu
* fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-13Use PRIuSIZE format specifier for size_t valuesrhe
Use PRIuSIZE instead of PRIdSIZE. This fixes the exception message shown on too large xmalloc2. This commit also fixes other incorrect use of PRIdSIZE in other functions; though most of them are debug print. * gc.c (heap_extend_pages, get_envparam_size, ruby_malloc_size_overflow, gc_profile_dump_on): Use PRIuSIZE instead of PRIdSIZE as the passed value is size_t, not ssize_t. * iseq.c (get_line_info, rb_iseq_disasm_insn): Ditto. * sprintf.c (rb_str_format): Ditto. * thread_win32.c (native_thread_create): Ditto. * vm.c (get_param): Ditto. * ext/objspace/objspace_dump.c (dump_append_string_content, dump_object): Ditto. * ext/socket/raddrinfo.c (host_str, port_str): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-06socket/depend: add srcs [ci skip]nobu
* ext/socket/depend (srcs): phony target to update confdefs source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-13getnameinfo.c: rubysocket.h for inet_ntopnobu
* ext/socket/getnameinfo.c: needs rubysocket.h for fallback definition of inet_ntop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-02socket/option.c: inet_ntopnobu
* ext/socket/option.c, ext/socket/rubysocket.h (inet_ntop): share the fallback definition. [ruby-core:76646] [Bug #12645] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29rb_funcallvnobu
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30* ext/socket/raddrinfo.c (host_str, port_str): Use StringValueCStrusa
instead of (Safe)StringValue, to detect NUL byte in the string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30raddrinfo.c: fix modifiernobu
* ext/socket/raddrinfo.c (host_str, port_str): fix length modifier to size_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30raddrinfo.c: fix for SHARABLE_MIDDLE_SUBSTRINGnobu
* ext/socket/raddrinfo.c (host_str, port_str): use RSTRING_LEN instead of strlen, since RSTRING_PTR StringValueCStr may not be NUL-terminated when SHARABLE_MIDDLE_SUBSTRING=1. reported by @tmtms, http://twitter.com/tmtms/status/736910516229005312 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11Update dependencies.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17socket/option.c: accurate conditionnobu
* ext/socket/option.c (inspect_tcpi_msec): more accurate condition for TCPI msec member inspection function. [ruby-core:74388] [Bug #12185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e