Sha256: 75e3c1b983b9e529af28454dac59818a4ab19fd83890b5ae89a99497808bd831

Contents?: true

Size: 557 Bytes

Versions: 8

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'

server1 = TCPServer.open('127.0.0.1', 1234)
server2 = TCPServer.open('127.0.0.1', 1235)

puts "Pid: #{Process.pid}"
puts 'Proxying port 1234 => port 1235'

client1 = client2 = nil

f1 = spin {
  client1 = server1.accept
  loop do
    if client2
      Thread.current.backend.splice_loop(client1, client2)
    end
  end
}

f2 = spin {
  client2 = server2.accept
  loop do
    if client1
      Thread.current.backend.splice_loop(client2, client1)
    end
  end
}

Fiber.await(f1, f2)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
polyphony-0.52.0 examples/io/tcp_proxy.rb
polyphony-0.51.0 examples/io/tcp_proxy.rb
polyphony-0.50.1 examples/io/tcp_proxy.rb
polyphony-0.50.0 examples/io/tcp_proxy.rb
polyphony-0.49.2 examples/io/tcp_proxy.rb
polyphony-0.49.1 examples/io/tcp_proxy.rb
polyphony-0.49.0 examples/io/tcp_proxy.rb
polyphony-0.48.0 examples/io/tcp_proxy.rb