[usocket-devel] socket-connect raises non-obvious conditions when given a bad host
Ryan Davis
ryan at acceleration.net
Fri Jan 11 19:52:00 UTC 2008
When I try to use socket-connect with a host that can't be resolved, it
throws an unhelpful error:
Couldn't write to #<SB-SYS:FD-STREAM for "a socket" {C0286C1}>:
Broken pipe
[Condition of type SB-INT:SIMPLE-STREAM-ERROR]
Restarts:
0: [ABORT] Return to SLIME's top level.
1: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread"
{B35FB79}>)
Backtrace:
0: (SB-IMPL::SIMPLE-STREAM-PERROR "Couldn't write to ~s"
#<SB-SYS:FD-STREAM for "a socket" {C0286C1}> 32)
1: (SB-IMPL::SIMPLE-STREAM-PERROR "Couldn't write to ~s"
#<SB-SYS:FD-STREAM for "a socket" {C0286C1}> 32)
2: (FORCE-OUTPUT #<SB-SYS:FD-STREAM for "a socket" {C0286C1}>)
3: (USOCKET-BAD-ERROR)
Here is my test program:
(defun usocket-bad-error ()
(let ((s (usocket:socket-stream
(usocket:socket-connect "doesntexist.example.com" 80))))
(format s "GET / HTTP/1.1")
(force-output s);;error thrown here
s))
Looking through the usocket code, what I would have liked here is a
bad-host-name condition thrown that I could handle. I initially thought
a good spot for this would be in socket-connect, if the ip variable is
nil, but upon looking at the usocket source so more, I'm not sure if
there's a better place for that.
Also, I was going to add this as a ticket on the usocket trac, but I
don't have permission to do that.
Thanks,
--
Ryan Davis
Acceleration.net
Director of Programming Services
2831 NW 41st street, suite B
Gainesville, FL 32606
Office: 352-335-6500 x 124
Fax: 352-335-6506
More information about the usocket-devel
mailing list