From: <ast...@gm...> - 2007-07-03 07:50:44
|
Btw, the reason I'm sending this is because, sometimes I get a (111, 'Connection refused') error. That means I have to check always if it's a tuple and a string? On 7/3/07, ast...@gm... <ast...@gm...> wrote: > It seems there is some problem with socket errors. (I'm using Win98) > > First version: > > import socket > def test(): > server, port = 'non.existent.server', 6667 > try: > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect((server, int(port))) > except socket.error, (err_value, err_msg): > print err_msg > > if __name__ == '__main__': > test() > > Result: > ValueError: unpack sequence too short > > ############################ > > Second version: > > import socket > def test(): > server, port = 'non.existent.server', 6667 > try: > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect((server, int(port))) > except socket.error, err_msg: > print err_msg > > if __name__ == '__main__': > test() > > Result: > Unmapped java exception: java.nio.channels.UnresolvedAddressException > > #### > > How should this socket error be handled? > > Thanks. > |