Sha256: 089f791da932a122cabc64f74d8a0d3b66dd74bb9b3ecb31ae6e76d93912cd7f

Contents?: true

Size: 688 Bytes

Versions: 5

Compression:

Stored size: 688 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'async/io'
require 'async/io/endpoint'
require 'async/io/unix_endpoint'

@endpoint = Async::IO::Endpoint.unix("/tmp/notify-test.sock", Socket::SOCK_DGRAM)
# address = Async::IO::Address.udp("127.0.0.1", 6778)
# @endpoint = Async::IO::AddressEndpoint.new(address)

def server
	@endpoint.bind do |server|
		puts "Receiving..."
		packet, address = server.recvfrom(512)
		
		puts "Received: #{packet} from #{address}"
	end
end

def client(data = "Hello World!")
	@endpoint.connect do |peer|
		puts "Sending: #{data}"
		peer.send(data)
		puts "Sent!"
	end
end

Async do |task|
	server_task = task.async do
		server
	end
	
	client
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async-container-0.16.5 examples/udppipe.rb
async-container-0.16.4 examples/udppipe.rb
async-container-0.16.3 examples/udppipe.rb
async-container-0.16.2 examples/udppipe.rb
async-container-0.16.1 examples/udppipe.rb