Merge branch 'master' of ssh://bitsetter.de:8090/netsl

This commit is contained in:
tkarrass 2013-11-03 13:38:28 +01:00
commit 9cf94bbcbb
2 changed files with 14 additions and 12 deletions

View File

@ -17,16 +17,19 @@
#include "net.h" #include "net.h"
// kleiner helfer // little helper
// auch von bejee geguttenbergt static void *get_in_addr(struct sockaddr *sa) {
// switch (sa->sa_family) {
void *get_in_addr(struct sockaddr *sa) case AF_INET:
{ return &(((struct sockaddr_in*)sa)->sin_addr);
if (sa->sa_family == AF_INET) { break;
return &(((struct sockaddr_in*)sa)->sin_addr); case AF_INET6:
return &(((struct sockaddr_in6*)sa)->sin6_addr);
break;
case AF_UNSPEC:
default:
return NULL;
} }
return &(((struct sockaddr_in6*)sa)->sin6_addr);
} }
@ -46,10 +49,10 @@ int run_server(const struct prog_info *pinfo, char *img, int w, int h) {
sprintf(portbuf, "%d", pinfo->port); sprintf(portbuf, "%d", pinfo->port);
if ((ret=getaddrinfo("255.255.255.255", portbuf, &hints, &servinfo)) != 0) { if ((ret=getaddrinfo("255.255.255.255", portbuf, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret)); fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret));
return 1; return 1;
} }
for(p = servinfo; p != NULL; p = p->ai_next) { for (p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
perror("talker: socket"); perror("talker: socket");
continue; continue;

View File

@ -6,7 +6,6 @@
#include "msg.h" // message serialization #include "msg.h" // message serialization
#include "display.h" // callback #include "display.h" // callback
void *get_in_addr(struct sockaddr *sa);
int run_server(const struct prog_info *pinfo, char *img, int w, int h); int run_server(const struct prog_info *pinfo, char *img, int w, int h);
int run_client(const struct prog_info *pinfo,void(*framecallback)(const struct message *, const struct prog_info *)); int run_client(const struct prog_info *pinfo,void(*framecallback)(const struct message *, const struct prog_info *));