ruby ipv6 socket error

M

Ma Yu

I want use ruby ipv6 socket
i write some test program at linux platform.

1\
///////////////////////////////////////////////////////////////////////
require 'socket'
socket=UDPSocket.new(Socket::AF_INET6)
socket.bind("::1",12121)
loop do
msg,sender=socket.recvfrom(100)
host=sender[3]
puts "#{Time.now}:#{host} '#{msg}'"
end
///////////////////////////////////////////////////////////////////////
it is right,server can receive client message.

2\
///////////////////////////////////////////////////////////////////////
require 'socket'
socket=UDPSocket.new() #Socket::AF_INET6
socket.bind("fe80::218:8bff:fe0d:e27c",12121) #linux ipv6 link
address
loop do
msg,sender=socket.recvfrom(100)
host=sender[3]
puts "#{Time.now}:#{host} '#{msg}'"
end
///////////////////////////////////////////////////////////////////////
Error the tip message is
in 'connect':Invalid argument - connect(2) (Errno::EINVAL) from server 5

someone can help me .why this simple program have error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top