summaryrefslogtreecommitdiff
path: root/mcastseed
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-07-17 14:19:55 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-07-17 14:19:55 +0200
commit96e0fd1e6571c41e102d4780f6e67c0736beef35 (patch)
treec670275f2ecb192026710dadf43bb005adafdfd1 /mcastseed
parenta430fa470e4b7dd06fb92a0c32d09d9e00bdc827 (diff)
downloadeficast-96e0fd1e6571c41e102d4780f6e67c0736beef35.tar.gz
eficast-96e0fd1e6571c41e102d4780f6e67c0736beef35.tar.bz2
eficast-96e0fd1e6571c41e102d4780f6e67c0736beef35.zip
Pedantic-aware code (decl before code)
Diffstat (limited to 'mcastseed')
-rw-r--r--mcastseed/src/msock.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/mcastseed/src/msock.c b/mcastseed/src/msock.c
index e5df8d6..191611d 100644
--- a/mcastseed/src/msock.c
+++ b/mcastseed/src/msock.c
@@ -18,6 +18,7 @@ SOCKET mcast_send_socket(char* multicastIP, char* multicastPort, int multicastT
SOCKET sock;
struct addrinfo hints = { 0 }; /* Hints for name lookup */
+ int status;
#ifdef WIN32
@@ -33,7 +34,6 @@ SOCKET mcast_send_socket(char* multicastIP, char* multicastPort, int multicastT
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_NUMERICHOST;
- int status;
if ((status = getaddrinfo(multicastIP, multicastPort, &hints, multicastAddr)) != 0 )
{
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
@@ -106,6 +106,9 @@ SOCKET mcast_recv_socket(char* multicastIP, char* multicastPort, int multicastRe
struct addrinfo* localAddr = 0; /* Local address to bind to */
struct addrinfo* multicastAddr = 0; /* Multicast Address */
int yes=1;
+ int status, optval;
+ socklen_t optval_len;
+ int dfltrcvbuf;
#ifdef WIN32
WSADATA trash;
@@ -117,7 +120,6 @@ SOCKET mcast_recv_socket(char* multicastIP, char* multicastPort, int multicastRe
/* Resolve the multicast group address */
hints.ai_family = PF_UNSPEC;
hints.ai_flags = AI_NUMERICHOST;
- int status;
if ((status = getaddrinfo(multicastIP, NULL, &hints, &multicastAddr)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
goto error;
@@ -161,9 +163,8 @@ SOCKET mcast_recv_socket(char* multicastIP, char* multicastPort, int multicastRe
}
/* get/set socket receive buffer */
- int optval=0;
- socklen_t optval_len = sizeof(optval);
- int dfltrcvbuf;
+ optval=0;
+ optval_len = sizeof(optval);
if(getsockopt(sock, SOL_SOCKET, SO_RCVBUF,(char*)&optval, &optval_len) !=0) {
perror("getsockopt");
goto error;
@@ -253,6 +254,7 @@ SOCKET ucast_client_socket(char* serverIP, char* serverPort) {
SOCKET sock;
struct addrinfo *serverAddr;
struct addrinfo hints = { 0 }; /* Hints for name lookup */
+ int status;
#ifdef WIN32
@@ -268,7 +270,6 @@ SOCKET ucast_client_socket(char* serverIP, char* serverPort) {
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICHOST;
- int status;
if ((status = getaddrinfo(serverIP, serverPort, &hints, &serverAddr)) != 0 )
{
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
@@ -303,6 +304,7 @@ SOCKET ucast_server_socket(char* serverPort, int maxPendingConnections) {
SOCKET sock;
struct addrinfo *serverAddr;
struct addrinfo hints = { 0 }; /* Hints for name lookup */
+ int status;
#ifdef WIN32
@@ -318,7 +320,6 @@ SOCKET ucast_server_socket(char* serverPort, int maxPendingConnections) {
hints.ai_family = PF_INET6;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
- int status;
if ((status = getaddrinfo(NULL, serverPort, &hints, &serverAddr)) != 0 )
{
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));