Module: ServerEngine::WinSock

Extended by:
Fiddle::Importer
Includes:
Fiddle::Win32Types
Defined in:
lib/serverengine/winsock.rb

Defined Under Namespace

Classes: WSAPROTOCOL_INFO

Constant Summary collapse

SockaddrIn =
struct(["short sin_family",
 "short sin_port",
 "long sin_addr",
 "char sin_zero[8]",
])
INVALID_SOCKET =
-1

Class Method Summary collapse

Class Method Details

.last_errorObject



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/serverengine/winsock.rb', line 82

def self.last_error
  # On Ruby 3.0 calling WSAGetLastError here can't retrieve correct error
  # code because Ruby's internal code resets it.
  # See also:
  # * https://github.com/ruby/fiddle/issues/72
  # * https://bugs.ruby-lang.org/issues/17813
  if Fiddle.respond_to?(:win32_last_socket_error)
    Fiddle.win32_last_socket_error || 0
  else
    self.WSAGetLastError
  end
end