summaryrefslogtreecommitdiff
path: root/news/knews/patches/patch-ai
blob: ea5f798cea7da17edc91b11cf8224c96bc1d043b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
$NetBSD: patch-ai,v 1.2 2001/02/24 22:40:40 tron Exp $

--- src/server.c.orig	Fri Jan  9 18:16:22 1998
+++ src/server.c	Sat Feb 24 23:24:45 2001
@@ -2,19 +2,21 @@
  *  Copyright (C) 1995, 1996  Karl-Johan Johnsson.
  */
 
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include "global.h"
 #include "child.h"
 #include "codes.h"
 #include "connect.h"
 #include "file.h"
 #include "resource.h"
+#include "sysdeps.h"
 #include "server.h"
 #include "util.h"
 #include "widgets.h"
 #include "xutil.h"
 
-#include "sysdeps.h"
-
 struct SERVER {
     int		fd;
     char	*buffer;
@@ -128,30 +130,35 @@
  *  tell != 0   means tell about errors
  *  tell >  1   means say what you're doing
  */
-int server_open(SERVER *server, struct SERV_ADDR *addr, int tell)
+int server_open(SERVER *server, SERV_ADDR *addr, int tell)
 {
     long	tmp;
 
-    server_close(server);
-    server->fd = open_socket();
-    if (server->fd < 0) {
-	set_message("Error: Failed to create socket!", True);
-	return -1;
-    }
-
-    if (tell > 1)
-	set_message("Server contacted, waiting for response...", False);
-
-    tmp = connect_socket(server->fd, addr);
-
-    if (tmp < 0 && would_block(server->fd, errno)) {
-	if (tell == 0)
-	    return 0; /* don't block */
-
-	tmp = 0;
-	do_wait(&server->fd, True, server->quit_func, server);
-	if (server->fd < 0)
+    while (addr) {
+	server_close(server);
+	server->fd = open_socket(addr);
+	if (server->fd < 0) {
+	    set_message("Error: Failed to create socket!", True);
 	    return -1;
+	}
+
+	if (tell > 1)
+	    set_message("Server contacted, waiting for response...", False);
+
+	tmp = connect_socket(server->fd, addr);
+
+	if (tmp < 0 && would_block(server->fd, errno)) {
+	    if (tell == 0)
+		return 0; /* don't block */
+
+	    tmp = 0;
+	    do_wait(&server->fd, True, server->quit_func, server);
+	    if (server->fd >= 0)
+		break;
+
+	}
+
+	addr = next_addr(addr);
     }
 
     server->buffer[0] = '\0';