Sha256: 1eb4a0879b37964f85cbd0e73aa62e092c3e19ef6fe3fc14a0a43759eceb7a4d

Contents?: true

Size: 1.05 KB

Versions: 23

Compression:

Stored size: 1.05 KB

Contents

require 'em_test_helper'
require 'socket'

class TestSockOpt < Test::Unit::TestCase
  def setup
    assert(!EM.reactor_running?)
    @port = next_port
  end

  def teardown
    assert(!EM.reactor_running?)
  end

  def test_set_sock_opt
    omit_if(windows?)
    omit_if(!EM.respond_to?(:set_sock_opt))

    val = nil
    test_module = Module.new do
      define_method :post_init do
        val = set_sock_opt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true
        EM.stop
      end
    end

    EM.run do
      EM.start_server '127.0.0.1', @port
      EM.connect '127.0.0.1', @port, test_module
    end

    assert_equal 0, val
  end

  def test_get_sock_opt
    omit_if(windows?)
    omit_if(!EM.respond_to?(:set_sock_opt))

    val = nil
    test_module = Module.new do
      define_method :connection_completed do
        val = get_sock_opt Socket::SOL_SOCKET, Socket::SO_ERROR
        EM.stop
      end
    end

    EM.run do
      EM.start_server '127.0.0.1', @port
      EM.connect '127.0.0.1', @port, test_module
    end

    assert_equal "\0\0\0\0", val
  end

end

Version data entries

23 entries across 21 versions & 2 rubygems

Version Path
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/eventmachine-1.2.7/tests/test_sock_opt.rb
eventmachine-1.2.7-java tests/test_sock_opt.rb
eventmachine-1.2.7-x64-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.7-x86-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.7 tests/test_sock_opt.rb
eventmachine-1.2.6-x64-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.6-x86-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.6-java tests/test_sock_opt.rb
eventmachine-1.2.6 tests/test_sock_opt.rb
eventmachine-1.2.5-x86-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.5-x64-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.5-java tests/test_sock_opt.rb
eventmachine-1.2.5 tests/test_sock_opt.rb
eventmachine-1.2.3-x64-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.3-x86-mingw32 tests/test_sock_opt.rb
eventmachine-1.2.3-java tests/test_sock_opt.rb
eventmachine-1.2.3 tests/test_sock_opt.rb
eventmachine-1.2.2-java tests/test_sock_opt.rb