Util: Fix socket code to not use struct designated initialization

This commit is contained in:
Jeffrey Pfau 2015-01-07 02:06:38 -08:00
parent aa12eeef3a
commit 9da3e5e1f9
1 changed files with 8 additions and 10 deletions

View File

@ -50,11 +50,10 @@ static inline Socket SocketOpenTCP(int port, uint32_t bindAddress) {
return sock; return sock;
} }
struct sockaddr_in bindInfo = { struct sockaddr_in bindInfo;
.sin_family = AF_INET, memset(&bindInfo, 0, sizeof(bindInfo));
.sin_port = htons(port), bindInfo.sin_family = AF_INET;
.sin_addr = { 0 } bindInfo.sin_port = htons(port);
};
bindInfo.sin_addr.s_addr = htonl(bindAddress); bindInfo.sin_addr.s_addr = htonl(bindAddress);
int err = bind(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in)); int err = bind(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in));
if (err) { if (err) {
@ -70,11 +69,10 @@ static inline Socket SocketConnectTCP(int port, uint32_t destinationAddress) {
return sock; return sock;
} }
struct sockaddr_in bindInfo = { struct sockaddr_in bindInfo;
.sin_family = AF_INET, memset(&bindInfo, 0, sizeof(bindInfo));
.sin_port = htons(port), bindInfo.sin_family = AF_INET;
.sin_addr = { 0 } bindInfo.sin_port = htons(port);
};
bindInfo.sin_addr.s_addr = htonl(destinationAddress); bindInfo.sin_addr.s_addr = htonl(destinationAddress);
int err = connect(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in)); int err = connect(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in));
if (err) { if (err) {