Initialize winsock in main.c

This commit is contained in:
Joseph C. Lehner 2016-02-05 20:23:16 +02:00
parent 590894deac
commit a1c9cc6e7f
2 changed files with 14 additions and 13 deletions

View file

@ -1,12 +0,0 @@
#include <inttypes.h>
#include <stdint.h>
struct ethsock;
struct ethsock *ethsock_create(const char *intf, uint16_t protocol);
int ethsock_close(struct ethsock *sock);
int ethsock_send(struct ethsock *sock, void *buf, size_t len);
ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len);
int ethsock_set_timeout(struct ethsock *sock, unsigned msec);
uint8_t *ethsock_get_hwaddr(struct ethsock *sock);
int ethsock_list_all(void);

15
main.c
View file

@ -76,6 +76,15 @@ int main(int argc, char **argv)
.port = 69,
.force_root = 1
};
#ifdef NMRPFLASH_WINDOWS
WSADATA wsa;
val = WSAStartup(MAKEWORD(2, 2), &wsa);
if (val != 0) {
win_perror2("WSAStartup", val);
return 1;
}
#endif
opterr = 0;
@ -145,5 +154,9 @@ int main(int argc, char **argv)
}
#endif
return nmrp_do(&args);
val = nmrp_do(&args);
#ifdef NMRPFLASH_WINDOWS
WSACleanup();
#endif
return val;
}