<s> from test import test_support <EOL> import socket <EOL> import time <EOL> skip_expected = not ( test_support . is_resource_enabled ( '<STR_LIT>' ) and <EOL> hasattr ( socket , "<STR_LIT>" ) ) <EOL> def test_basic ( ) : <EOL> test_support . requires ( '<STR_LIT>' ) <EOL> import urllib <EOL> socket . RAND_status ( ) <EOL> try : <EOL> socket . RAND_egd ( <NUM_LIT:1> ) <EOL> except TypeError : <EOL> pass <EOL> else : <EOL> print "<STR_LIT>" <EOL> socket . RAND_add ( "<STR_LIT>" , <NUM_LIT> ) <EOL> f = urllib . urlopen ( '<STR_LIT>' ) <EOL> buf = f . read ( ) <EOL> f . close ( ) <EOL> def test_rude_shutdown ( ) : <EOL> if test_support . is_jython : <EOL> return <EOL> try : <EOL> import thread <EOL> except ImportError : <EOL> return <EOL> PORT = <NUM_LIT> <EOL> def listener ( ) : <EOL> s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> s . bind ( ( '<STR_LIT>' , PORT ) ) <EOL> s . listen ( <NUM_LIT:5> ) <EOL> s . accept ( ) <EOL> del s <EOL> thread . exit ( ) <EOL> def connector ( ) : <EOL> s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> s . connect ( ( '<STR_LIT:localhost>' , PORT ) ) <EOL> try : <EOL> ssl_sock = socket . ssl ( s ) <EOL> except socket . sslerror : <EOL> pass <EOL> else : <EOL> raise test_support . TestFailed , '<STR_LIT>' <EOL> thread . start_new_thread ( listener , ( ) ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> connector ( ) <EOL> def test_main ( ) : <EOL> if not hasattr ( socket , "<STR_LIT>" ) : <EOL> raise test_support . TestSkipped ( "<STR_LIT>" ) <EOL> test_rude_shutdown ( ) <EOL> test_basic ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
