| 729 | } |
| 730 | |
| 731 | static int connTLSConnect(connection *conn_, const char *addr, int port, const char *src_addr, ConnectionCallbackFunc connect_handler) { |
| 732 | tls_connection *conn = (tls_connection *) conn_; |
| 733 | |
| 734 | if (conn->c.state != CONN_STATE_NONE) return C_ERR; |
| 735 | ERR_clear_error(); |
| 736 | |
| 737 | /* Initiate Socket connection first */ |
| 738 | if (CT_Socket.connect(conn_, addr, port, src_addr, connect_handler) == C_ERR) return C_ERR; |
| 739 | |
| 740 | /* Return now, once the socket is connected we'll initiate |
| 741 | * TLS connection from the event handler. |
| 742 | */ |
| 743 | return C_OK; |
| 744 | } |
| 745 | |
| 746 | static int connTLSWrite(connection *conn_, const void *data, size_t data_len) { |
| 747 | tls_connection *conn = (tls_connection *) conn_; |