Sha256: e9f69600a3e7c9dc8f6382124febad379da9fac170ba498d845481fd5ce3562f

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

require_relative 'helper'

class SocketTest < MiniTest::Test
  def setup
    super
  end

  def test_tcp
    server = TCPServer.new('127.0.0.1', 1234)

    server_fiber = spin do
      while (socket = server.accept)
        spin do
          while (data = socket.gets(8192))
            socket << data
          end
        end
      end
    end

    snooze
    client = TCPSocket.new('127.0.0.1', 1234)
    client.write("1234\n")
    assert_equal "1234\n", client.readpartial(8192)
    client.close
  ensure
    server_fiber.stop
    snooze
    server&.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polyphony-0.42 test/test_socket.rb
polyphony-0.41 test/test_socket.rb