| 100 | } |
| 101 | |
| 102 | static int connSocketConnect(connection *conn, const char *addr, int port, const char *src_addr, |
| 103 | ConnectionCallbackFunc connect_handler) { |
| 104 | int fd = anetTcpNonBlockBestEffortBindConnect(NULL,addr,port,src_addr); |
| 105 | if (fd == -1) { |
| 106 | conn->state = CONN_STATE_ERROR; |
| 107 | conn->last_errno = errno; |
| 108 | return C_ERR; |
| 109 | } |
| 110 | |
| 111 | conn->fd = fd; |
| 112 | conn->state = CONN_STATE_CONNECTING; |
| 113 | |
| 114 | conn->conn_handler = connect_handler; |
| 115 | aeCreateFileEvent(server.el, conn->fd, AE_WRITABLE, |
| 116 | conn->type->ae_handler, conn); |
| 117 | |
| 118 | return C_OK; |
| 119 | } |
| 120 | |
| 121 | /* Returns true if a write handler is registered */ |
| 122 | int connHasWriteHandler(connection *conn) { |
nothing calls this directly
no test coverage detected