# IPSocket::getaddress problem

**URL:** <https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077>\
**Category:** Ruby\
**Created:** [August 15, 2007, 12:52am UTC](https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077 "2007-08-15T00:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![h4z3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/54ee81/32.png) [@h4z3](https://www.ruby-forum.com/u/h4z3)\
**Post date:** [August 15, 2007, 12:52am UTC](https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077/1 "2007-08-15T00:52:43Z")

</div>

Hey guys, I want to test if IPSocket::getaddress(‘address’) is valid  
before printing it or anything…

If the user enters an invalid address then the program dies, i tried  
rescuing the error but i didn’t have much luck, any ideas?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![h4z3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/54ee81/32.png) [@h4z3](https://www.ruby-forum.com/u/h4z3)\
**Post date:** [August 15, 2007, 1:26am UTC](https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077/2 "2007-08-15T01:26:52Z")

</div>

_BUMP_

Seriously, No-one?

---

<div class="post-metadata">

**Author:** ![h4z3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/54ee81/32.png) [@h4z3](https://www.ruby-forum.com/u/h4z3)\
**Post date:** [August 15, 2007, 4:22am UTC](https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077/3 "2007-08-15T04:22:00Z")

</div>

success = false  
begin  
a = IPSocket::getaddress(‘their input’)  
success = true  
rescue Exception =\> detail

# arr! evil address

success = false  
end

Haze N. wrote:

> Hey guys, I want to test if IPSocket::getaddress(‘address’) is valid  
> before printing it or anything…
> 
> If the user enters an invalid address then the program dies, i tried  
> rescuing the error but i didn’t have much luck, any ideas?
> 
> Thanks in advance

---

<div class="post-metadata">

**Author:** ![h4z3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/54ee81/32.png) [@h4z3](https://www.ruby-forum.com/u/h4z3)\
**Post date:** [August 15, 2007, 2:43am UTC](https://www.ruby-forum.com/t/ipsocket-getaddress-problem/112077/4 "2007-08-15T02:43:24Z")

</div>

On Aug 14, 2007, at 5:52 PM, Haze N. wrote:

> Hey guys, I want to test if IPSocket::getaddress(‘address’) is valid  
> before printing it or anything…
> 
> If the user enters an invalid address then the program dies, i tried  
> rescuing the error but i didn’t have much luck, any ideas?
> 
> ## Thanks in advance
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Try creating a test first.  
Using testing facilities in Ruby is exactly for this kind of thing!
