diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/chat.c | 7 | ||||
-rw-r--r-- | mbbsd/talk.c | 9 |
2 files changed, 3 insertions, 13 deletions
diff --git a/mbbsd/chat.c b/mbbsd/chat.c index 8527a41f..27cd2d38 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -309,7 +309,6 @@ t_chat(void) char chatroom[IDLEN];/* Chat-Room Name */ char inbuf[80], chatid[20], lastcmd[MAXLASTCMD][80], *ptr = ""; struct sockaddr_in sin; - struct hostent *h; int cfd, cmdpos, ch; int currchar; int chatting = YEA; @@ -325,16 +324,12 @@ t_chat(void) memset(&chatbuf, 0, sizeof(chatbuf)); outs(" 驅車前往 請梢候........ "); - if (!(h = gethostbyname("localhost"))) { - perror("gethostbyname"); - return -1; - } memset(&sin, 0, sizeof sin); #ifdef __FreeBSD__ sin.sin_len = sizeof(sin); #endif sin.sin_family = PF_INET; - memcpy(&sin.sin_addr, h->h_addr, h->h_length); + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = htons(NEW_CHATPORT); cfd = socket(sin.sin_family, SOCK_STREAM, 0); if (connect(cfd, (struct sockaddr *) & sin, sizeof sin) != 0) { diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 11b1abfb..408c9ac8 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -3107,19 +3107,14 @@ int establish_talk_connection(const userinfo_t *uip) { int a; - struct hostent *h; struct sockaddr_in sin; currutmp->msgcount = 0; strlcpy(save_page_requestor, page_requestor, sizeof(save_page_requestor)); memset(page_requestor, 0, sizeof(page_requestor)); - if (!(h = gethostbyname("localhost"))) { - perror("gethostbyname"); - return -1; - } memset(&sin, 0, sizeof(sin)); - sin.sin_family = h->h_addrtype; - memcpy(&sin.sin_addr, h->h_addr, h->h_length); + sin.sin_family = PF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = uip->sockaddr; if ((a = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) { perror("connect err"); |