A
Anukul Singhal
Hi,
I am new to Socket programming in ruby and want to connect to a device.
I am able to make a connection using the following code but failing in
the bind method. Here's the snippet:
require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
puts socket.inspect (returns #<Socket:0x2b85694>)
sockaddr = Socket.pack_sockaddr_in(5555,'114.23.42.42')
puts sockaddr.inspect (returns
"\002\000\025\263\217[\"\315\000\000\000\000\000\000\000\000")
bound = socket.bind(sockaddr)
puts bound.inspect
In the last method bind, getting the following error:
Test.rb:50:in `bind': The requested address is not valid in its context.
- bind(2) (Errno::EADDRNOTAVAIL)
I think I might be missing something elementary here. If anyone can
please help with it, would be really grateful.
Thanks,
Anukul
I am new to Socket programming in ruby and want to connect to a device.
I am able to make a connection using the following code but failing in
the bind method. Here's the snippet:
require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
puts socket.inspect (returns #<Socket:0x2b85694>)
sockaddr = Socket.pack_sockaddr_in(5555,'114.23.42.42')
puts sockaddr.inspect (returns
"\002\000\025\263\217[\"\315\000\000\000\000\000\000\000\000")
bound = socket.bind(sockaddr)
puts bound.inspect
In the last method bind, getting the following error:
Test.rb:50:in `bind': The requested address is not valid in its context.
- bind(2) (Errno::EADDRNOTAVAIL)
I think I might be missing something elementary here. If anyone can
please help with it, would be really grateful.
Thanks,
Anukul