/* Creates and connects to an unsecure socket to be used for SMTP.  */
static int8_t smtpConnect(void)
/* Creates and connects to an unsecure socket to be used for SMTP.  */
static int8_t smtpConnect(void)
{
	struct sockaddr_in addr_in;
	addr_in.sin_family = AF_INET;
	addr_in.sin_port = _htons(MAIN_GMAIL_HOST_PORT);
	addr_in.sin_addr.s_addr = gu32HostIp;
	if (tcp_client_socket < 0) {
		tcp_client_socket = socket(AF_INET, SOCK_STREAM, SOCKET_FLAGS_SSL);
	}
	if (tcp_client_socket == -1) {
		printf("socket error.\r\n");
		close(tcp_client_socket);
		return -1;
	}
	if (connect(tcp_client_socket, (struct sockaddr *)&addr_in, sizeof(struct sockaddr_in)) != SOCK_ERR_NO_ERROR) {
		printf("connect error.\r\n");
		return SOCK_ERR_INVALID;
	}
	return SOCK_ERR_NO_ERROR;
}