From 26db4f6adf5a43f49b7941bab90c05c1e271d6b0 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 12 May 2010 18:12:37 -0700 Subject: Fallback on other transports. This adds support for --disable-unix-transport Signed-off-by: Jeremy Huddleston --- fd.c | 13 +++++++++---- fd.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fd.c b/fd.c index 0945d41..0298727 100644 --- a/fd.c +++ b/fd.c @@ -258,7 +258,7 @@ AcceptConnection ( FD MakeConnection( - char *server, + const char *server, short port, int report, XtransConnInfo *trans_conn /* transport connection object */ @@ -268,9 +268,14 @@ MakeConnection( #ifdef USE_XTRANS char address[256]; int connect_stat; - - snprintf (address, sizeof(address), "%s:%ld", server, port - ServerBasePort); - if ( (*trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) { + const char *protocols[] = {"local", "unix", "tcp", "inet6", "inet", NULL}; + const char **s; + + for(*trans_conn = NULL, s = protocols; *trans_conn == NULL && *s; s++) { + snprintf (address, sizeof(address), "%s/%s:%ld", *s, server, port - ServerBasePort); + *trans_conn = _X11TransOpenCOTSClient(address); + } + if(*trans_conn == NULL) { debug(1,(stderr, "OpenCOTSClient failed\n")); panic("Can't open connection to Server"); } diff --git a/fd.h b/fd.h index 70e437d..3815210 100644 --- a/fd.h +++ b/fd.h @@ -96,7 +96,7 @@ extern void UsingFD(FD fd, void (*Handler)(int), void (*FlushHandler)(int), extern void NotUsingFD(FD fd); extern FD AcceptConnection (FD ConnectionSocket); -extern FD MakeConnection (char *server, short port, int report, +extern FD MakeConnection (const char *server, short port, int report, XtransConnInfo *trans_conn); extern int MainLoop(void); -- cgit v1.2.3