20 Commits

Author SHA1 Message Date
Chris Hasiński b85c520843 Remove stale self-corruption workaround in recvfrom_nonblock
The s = self workaround and XXX comment in recvfrom_nonblock date back
to the initial import of mruby-socket. The underlying bug where self
became a SystemcallException inside ensure blocks has since been fixed.

Verified that self correctly refers to the socket object in ensure
blocks after exceptions from recvfrom.
2026-03-30 22:14:26 +02:00
Yukihiro "Matz" Matsumoto 3cc4a77f49 mruby-socket: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto b817e2e7e2 mruby-socket: add comprehensive call-seq documentation for Ruby and C methods
Added complete call-seq documentation for socket programming methods across
all major socket classes in both mrblib/socket.rb (64 Ruby methods) and
src/socket.c (35 C methods):

- Addrinfo: Complete documentation for address information handling including
  creation (new, foreach, ip, tcp, udp, unix), inspection (inspect,
  inspect_sockaddr, to_s), address queries (afamily, pfamily, ipv4?, ipv6?,
  ip?, unix?), data extraction (ip_address, ip_port, ip_unpack, unix_path),
  and conversion methods (to_sockaddr, getnameinfo)

- BasicSocket: Core socket functionality including class configuration
  (do_not_reverse_lookup, do_not_reverse_lookup=), object creation (for_fd),
  address retrieval (local_address, remote_address), and non-blocking
  operations (recv_nonblock)

- IPSocket: Internet protocol socket operations including address information
  (addr, peeraddr), connection methods (bind, connect), data transfer
  (send, recvfrom, recvfrom_nonblock), and address resolution (getaddress)

- TCPSocket/TCPServer: TCP client and server socket operations including
  connection establishment (new, open), server operations (accept,
  accept_nonblock, listen, sysaccept)

- UDPSocket: UDP socket operations for datagram communication including
  initialization and internal address handling

- Socket: Low-level socket operations including creation (new, open),
  address manipulation (sockaddr_in, sockaddr_un, unpack_sockaddr_in,
  unpack_sockaddr_un), connection management (bind, connect, listen),
  data transfer (recvfrom, recvfrom_nonblock), socket pairs (pair),
  and name resolution (getaddrinfo, getnameinfo)

- UNIXSocket/UNIXServer: Unix domain socket operations for local IPC
  including creation (new, socketpair), path handling (path, addr, peeraddr),
  server operations (accept, accept_nonblock, listen, sysaccept), and
  data transfer (recvfrom)

- Addrinfo: Core address resolution methods including getaddrinfo for name
  resolution, getnameinfo for reverse lookups, and unix_path for Unix
  domain socket paths

- BasicSocket: Low-level socket operations including getpeereid for peer
  credentials, getpeername/getsockname for address retrieval, recv/send
  for data transfer, getsockopt/setsockopt for option management,
  shutdown for connection termination, and Windows-specific overrides
  (close, sysread, sysseek, syswrite)

- IPSocket: Internet protocol utilities including ntop/pton for address
  conversion and recvfrom for receiving data with sender information

- Socket: Core socket creation and management including gethostname,
  internal methods (_accept, _bind, _connect, _listen, _socket),
  address utilities (sockaddr_un, socketpair), and platform-specific
  implementations

- Socket::Option: Socket option handling including creation from boolean/
  integer values, accessor methods (family, level, optname, data),
  type conversion (int, bool), and debugging support (inspect)

All methods now have comprehensive call-seq documentation with practical
This significantly improves maintainability and usability of errno
handling for developers working with system call errors and file
operations in embedded Ruby environments.

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:44 +09:00
Yukihiro "Matz" Matsumoto f7813268d6 mruby-socket: inline #_new_with_prelude that is only called once. 2025-06-14 13:39:12 +09:00
Yukihiro "Matz" Matsumoto bf0f37833d mruby-socket: fixed raising RuntimeError from #accept; #6554
In mruby, bare `raise` in rescue clause does not re-raise the last
exception. You should explicitly specify the exception.
2025-06-14 01:56:43 +09:00
Yukihiro "Matz" Matsumoto b5197c22f6 mruby-socket: should not directly call private #initialize; fix #6554 2025-06-10 14:28:26 +09:00
Yukihiro "Matz" Matsumoto 921a54ef33 mruby-socket/socket.rb: done some small refactoring 2024-06-14 06:14:27 +09:00
Yukihiro "Matz" Matsumoto 771b56c796 mruby-socket: hide internal method new_with_prelude
- rename new_with_prelude to _new_with_prelude
- take a block instead of proc
2023-09-28 14:36:42 +09:00
Yukihiro "Matz" Matsumoto 8afb73f3e2 mruby-socket/socket.rb: should not call unix_path for non UNIX Addrinfo
ref #6051
2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 2160be7db7 mruby-socket/socket.rb: remove unused canonname accessor 2023-08-22 23:27:08 +09:00
Yukihiro "Matz" Matsumoto 58e10f16e9 mruby-socket/socket.c: include Socket::Constants in C init 2023-08-16 13:23:56 +09:00
Yukihiro "Matz" Matsumoto 1d7c00e920 mruby-socket/socket.c: implement whole Socket::Option class in C
`mruby-pack` gem no longer needed.
2023-08-15 15:29:36 +09:00
Yukihiro "Matz" Matsumoto 83b6a63c16 mruby-socket/socket.c: implement accessors in C 2023-08-15 07:35:29 +09:00
Yukihiro "Matz" Matsumoto 892596d372 mruby-socket/socket.c: implement Socket::Option#initialize in C 2023-08-14 23:32:22 +09:00
Yukihiro "Matz" Matsumoto 0866fa38b0 Avoid unnecessary object allocation (addrinfo) in _accept; ref #3999 2018-04-18 00:18:03 +09:00
Yukihiro "Matz" Matsumoto 4880f6dc89 Socket.accept should have returned [fd, addr]; fix #3999 2018-04-17 17:21:49 +09:00
Yukihiro "Matz" Matsumoto 16e473caad Rename BasicSocket#is_socket= to #_is_socket; ref #3878 2017-12-14 00:07:42 +09:00
Takeshi Watanabe d2163d13a8 Declare super class in socket.rb. 2017-12-14 00:05:23 +09:00
Takeshi Watanabe 949bf6ca43 Fix socket closing by using closesocket API in windows instead. 2017-12-14 00:05:23 +09:00
Yukihiro "Matz" Matsumoto 73ef548c63 Add 'mrbgems/mruby-socket/' from commit 'ab54185005ec87fe4f5b10df95ad29659884141b'
git-subtree-dir: mrbgems/mruby-socket
git-subtree-mainline: d75266dd1b
git-subtree-split: ab54185005
2017-12-07 18:11:13 +09:00