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,