Example #1
0
static int connect_ssl(struct in_addr *addr, int port) {
  if (conn_sock(&server.conn, addr, port)) {
    return -1;
  }
  server.conn.sslcon = openssl_connect_fd(server.env, server.conn.sock, 10);
  if (!server.conn.sslcon) {
    syslog(LOG_ERR, "%s: Failed to connect to %s:%d", strerror(errno), inet_ntoa(*addr), port);
    return -1;
  }
  return 0;
}
Example #2
0
int conn_setup(struct conn_t *conn, char *hostname, 
	       int port, bstring bwrite, bstring bread) {
  struct hostent *host;

  conn->write_pos = 0;
  conn->write_buf = bwrite;
  conn->read_pos = 0;
  conn->read_buf = bread;

  if (!(host = gethostbyname(hostname)) || !host->h_addr_list[0]) {
    log_err(0, "Could not resolve IP address of uamserver: %s! [%s]", 
	    hostname, strerror(errno));
    return -1;
  }

  return conn_sock(conn, (struct in_addr *)host->h_addr_list[0], port);
}