module ServerEngine::SocketManagerWin::ClientModule

Private Instance Methods

connect_peer(addr) click to toggle source
# File lib/serverengine/socket_manager_win.rb, line 29
def connect_peer(addr)
  return TCPSocket.open("127.0.0.1", addr)
end
recv(family, proto, peer, sent) click to toggle source
# File lib/serverengine/socket_manager_win.rb, line 33
def recv(family, proto, peer, sent)
  server_class, protocol = case proto
                           when :tcp then [TCPServer, Socket::SOCK_STREAM]
                           when :udp then [UDPSocket, Socket::SOCK_DGRAM]
                           else
                             raise ArgumentError, "invalid protocol: #{proto}"
                           end

  proto_info = WinSock::WSAPROTOCOL_INFO.from_bin(sent)

  handle = WinSock.WSASocketA(family, protocol, 0, proto_info, 0, 1)
  if handle == WinSock::INVALID_SOCKET
    RbWinSock.raise_last_error("WSASocketA(2)")
  end

  return RbWinSock.wrap_io_handle(server_class, handle, 0)
end
recv_tcp(family, peer, sent) click to toggle source
# File lib/serverengine/socket_manager_win.rb, line 51
def recv_tcp(family, peer, sent)
  recv(family, :tcp, peer, sent)
end
recv_udp(family, peer, sent) click to toggle source
# File lib/serverengine/socket_manager_win.rb, line 55
def recv_udp(family, peer, sent)
  recv(family, :udp, peer, sent)
end