On Mon, Mar 09, 2009 at 03:22:51PM +0100,
 Stephane Bortzmeyer <[email protected]> wrote 
 a message of 25 lines which said:

> The atatched code test1.py runs fine but a small modification, adding
> a timeout to the socket (test-timeout.py) crashes with:

And here is the promised code.
import socket
import os
import sys

from gnutls.crypto import *
from gnutls.connection import *

script_path = os.path.realpath(os.path.dirname(sys.argv[0]))
certs_path = os.path.join(script_path, 'certs')

cert = X509Certificate(open(certs_path + '/valid.crt').read())
key = X509PrivateKey(open(certs_path + '/valid.key').read())
cred = X509Credentials(cert, key)

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
session = ClientSession(sock, cred)

session.connect(('www.afnic.fr', 443))
session.handshake()
session.send("HEAD / HTTP/1.0\r\n\r\n")
buf = session.recv(1024)
print buf
session.bye()
session.shutdown()
session.close()
import socket
import os
import sys

from gnutls.crypto import *
from gnutls.connection import *

script_path = os.path.realpath(os.path.dirname(sys.argv[0]))
certs_path = os.path.join(script_path, 'certs')

cert = X509Certificate(open(certs_path + '/valid.crt').read())
key = X509PrivateKey(open(certs_path + '/valid.key').read())
cred = X509Credentials(cert, key)

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(3)
session = ClientSession(sock, cred)

session.connect(('www.afnic.fr', 443))
session.handshake()
session.send("HEAD / HTTP/1.0\r\n\r\n")
buf = session.recv(1024)
print buf
session.bye()
session.shutdown()
session.close()
_______________________________________________
Help-gnutls mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnutls

Reply via email to