3 --- src/server.c.orig Fri Jan 9 18:16:22 1998
4 +++ src/server.c Mon Mar 12 14:11:00 2001
6 * Copyright (C) 1995, 1996 Karl-Johan Johnsson.
9 +#include <sys/types.h>
10 +#include <sys/socket.h>
30 * tell != 0 means tell about errors
31 * tell > 1 means say what you're doing
33 -int server_open(SERVER *server, struct SERV_ADDR *addr, int tell)
34 +int server_open(SERVER *server, SERV_ADDR *addr, int tell)
40 - server->fd = open_socket();
41 - if (server->fd < 0) {
42 - set_message("Error: Failed to create socket!", True);
46 + server->fd = open_socket(addr);
47 + if (server->fd < 0) {
48 + set_message("Error: Failed to create socket!", True);
53 - set_message("Server contacted, waiting for response...", False);
55 + set_message("Server contacted, waiting for response...", False);
57 - tmp = connect_socket(server->fd, addr);
58 + if (connect_socket(server->fd, addr) == 0)
61 - if (tmp < 0 && would_block(server->fd, errno)) {
63 - return 0; /* don't block */
66 - do_wait(&server->fd, True, server->quit_func, server);
69 + if (would_block(server->fd, errno)) {
71 + return 0; /* don't block */
73 + do_wait(&server->fd, True, server->quit_func, server);
83 + length = sizeof(error);
84 + if (getsockopt(server->fd, SOL_SOCKET, SO_ERROR,
85 + (char *)&error, &length) == 0) {
94 + server_close(server);
95 + addr = next_addr(addr);
98 + if (server->fd < 0) {
101 + char *tmp = error_string(errno);
104 + tmp = "Connection failed";
105 + sprintf(message, "Error: %s!", tmp);
106 + set_message(message, True);
111 server->buffer[0] = '\0';
114 - tmp = read(server->fd, server->buffer, server->len);
115 - } while (tmp < 0 && errno == EINTR);
117 + tmp = read(server->fd, server->buffer, server->len);
118 + } while (tmp < 0 && errno == EINTR);
121 server->buffer[tmp] = '\0';