Projects
Multimedia
dvswitch-git
listen_wildcard.diff
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File listen_wildcard.diff of Package dvswitch-git
--- src/dvswitch.cpp | 11 +++++++++-- src/socket.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) Index: dvswitch-0.9-1-da15ba4/src/socket.c =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/socket.c +++ dvswitch-0.9-1-da15ba4/src/socket.c @@ -64,10 +64,25 @@ int create_listening_socket(const char * .ai_socktype = SOCK_STREAM, .ai_flags = AI_ADDRCONFIG }; struct addrinfo * addr; int error; + + if (!strcmp(host, "*")) + { + /* + * Manual page getaddrinfo(3) says: + * If the AI_PASSIVE flag is specified in hints.ai_flags, and node + * is NULL, then the returned socket addresses will be suitable + * for bind(2)ing a socket that will accept(2) connections. The + * returned socket address will contain the "wildcard address" + */ + host = NULL; + addr_hints.ai_flags |= AI_PASSIVE; + } + // fprintf(stderr, "getaddrinfo %s %s\n", host, port); + if ((error = getaddrinfo(host, port, &addr_hints, &addr))) { fprintf(stderr, "ERROR: getaddrinfo: %s\n", gai_strerror(error)); exit(1); } Index: dvswitch-0.9-1-da15ba4/src/dvswitch.cpp =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/dvswitch.cpp +++ dvswitch-0.9-1-da15ba4/src/dvswitch.cpp @@ -37,27 +37,31 @@ namespace {NULL, 0, NULL, 0} }; std::string mixer_host; std::string mixer_port; + std::string listen_addr; extern "C" { void handle_config(const char * name, const char * value) { if (std::strcmp(name, "MIXER_HOST") == 0) mixer_host = value; else if (strcmp(name, "MIXER_PORT") == 0) mixer_port = value; + else if (strcmp(name, "LISTEN") == 0) + listen_addr = value; } } void usage(const char * progname) { std::cerr << "\ Usage: " << progname << " [gtk-options] \\\n\ - [{-h|--host} LISTEN-HOST] [{-p|--port} LISTEN-PORT] [{-o|--osc} OSC-PORT]\n"; + [{-h|--host} LISTEN-HOST] [{-p|--port} LISTEN-PORT] [{-o|--osc} OSC-PORT]\\\n\ + (use --host '*' for INADDR_ANY)\n"; } } int main(int argc, char **argv) { @@ -78,11 +82,11 @@ int main(int argc, char **argv) while ((opt = getopt_long(argc, argv, "h:p:o:", options, NULL)) != -1) { switch (opt) { case 'h': - mixer_host = optarg; + listen_addr = mixer_host = optarg; break; case 'p': mixer_port = optarg; break; case 'o': /* --osc */ @@ -101,10 +105,13 @@ int main(int argc, char **argv) { std::cerr << argv[0] << ": mixer hostname and port not defined\n"; return 2; } + if (!listen_addr.empty()) + mixer_host = listen_addr; + // The mixer must be created before the window, since we pass // a reference to the mixer into the window's constructor to // allow it to adjust the mixer's controls. // However, the mixer must also be destroyed before the // window, since as long as it exists it may call into the
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.