3.3.2 Connection objects
Connection objects have the following methods:
- accept()
-
Call the accept method of the underlying socket and set up SSL on the
returned socket, using the Context object supplied to this Connection object at
creation. Returns a pair
(conn, address)
. where conn
is the new Connection object created, and address is as returned by the
socket's accept.
- bind(address)
-
Call the bind method of the underlying socket.
- close()
-
Call the close method of the underlying socket. Note: If you want
correct SSL closure, you need to call the shutdown method first.
- connect(address)
-
Call the connect method of the underlying socket and set up SSL on the
socket, using the Context object supplied to this Connection object at
creation.
- fileno()
-
Retrieve the file descriptor number for the underlying socket.
- listen(backlog)
-
Call the listen method of the underlying socket.
- get_app_data()
-
Retrieve application data as set by set_app_data.
- get_cipher_list([index])
-
Retrieve the cipher suite of the Connection object, matching the index
parameter. The default value of index is 0.
- get_context()
-
Retrieve the Context object associated with this Connection.
- get_peer_certificate()
-
Retrieve the other side's certificate (if any)
- getpeername()
-
Call the getpeername method of the underlying socket.
- getsockname()
-
Call the getsockname method of the underlying socket.
- getsockopt(level, optname[, buflen])
-
Call the getsockopt method of the underlying socket.
- pending()
-
Retrieve the number of bytes that can be safely read from the SSL buffer.
- recv(bufsize)
-
Receive data from the Connection. The return value is a string representing the
data received. The maximum amount of data to be received at once, is specified
by bufsize.
- renegotiate()
-
Renegotiate the SSL session. Call this if you wish to change cipher suites or
anything like that.
- send(string)
-
Send the string data to the Connection.
- set_accept_state()
-
Set the connection to work in server mode. The handshake will be handled
automatically by read/write.
- set_app_data(data)
-
Associate data with this Connection object. data can be retrieved
later using the get_app_data method.
- set_connect_state()
-
Set the connection to work in client mode. The handshake will be handled
automatically by read/write.
- setblocking(flag)
-
Call the setblocking method of the underlying socket.
- setsockopt(level, optname, value)
-
Call the setsockopt method of the underlying socket.
- shutdown()
-
Send the shutdown message to the Connection. Returns true if the shutdown
message exchange is completed and false otherwise (in which case you call
recv() or send() when the connection becomes
readable/writeable.
- sock_shutdown(how)
-
Call the shutdown method of the underlying socket.
- state_string()
-
Retrieve a verbose string detailing the state of the Connection.
- want_read()
-
Checks if more data has to be read from the transport layer to complete an
operation.
- want_write()
-
Checks if there is data to write to the transport layer to complete an
operation.