Я знаю, это просто, но я не мог получить это.
Я использую ОС Ubuntu. Следующий код был написан в исходном коде mysql (в файле sql_parse.cc). Мне нужно проверить сообщение об ошибке perror. Как я могу получить эти сообщения?
Я не думаю, что эти сообщения об ошибках будут отображаться в консоли, где я запускаю клиент / сервер mysql?
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
{
string hashed;
int sockfd, n;
char buf[MAXDATASIZE], url[MAXDATASIZE], ack[6];
struct hostent *he;
struct sockaddr_in remote_addr;
if ((he=gethostbyname("localhost")) == NULL) { // get the host info
perror("gethostbyname");
exit(1);
}
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
exit(1);
}
remote_addr.sin_family = AF_INET; // host byte order
remote_addr.sin_port = htons(PORT); // short, network byte order
remote_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(remote_addr.sin_zero), '\0', 8); // zero the rest of the struct
if (connect(sockfd, (struct sockaddr *)&remote_addr, sizeof(struct sockaddr)) == -1) {
perror("connect");
exit(1);
}
Пожалуйста, помогите мне ....