ported to windows

This commit is contained in:
cozis
2023-05-16 00:21:04 +02:00
parent 43ee04a2db
commit b259bb74db
16 changed files with 317 additions and 282 deletions
+2
View File
@@ -1,3 +1,4 @@
/*
#include <stdio.h>
#include <microtcp.h>
@@ -54,3 +55,4 @@ handled:
microtcp_destroy(mtcp);
return 0;
}
*/
+6 -4
View File
@@ -6,8 +6,10 @@ int main(void)
microtcp_errcode_t errcode;
microtcp_t *mtcp = microtcp_create("10.0.0.5", "10.0.0.4", NULL, NULL);
if (mtcp == NULL)
if (mtcp == NULL) {
fprintf(stderr, "Error: Failed to instanciate microtcp stack\n");
return -1;
}
uint16_t port = 80;
microtcp_socket_t *server = microtcp_open(mtcp, port, &errcode);
@@ -36,21 +38,21 @@ int main(void)
fprintf(stderr, "Error: %s\n", microtcp_strerror(errcode));
goto handled;
}
fprintf(stderr, "(%ld bytes received)\n", num);
fprintf(stderr, "(%d bytes received)\n", (int) num);
size_t sent1 = microtcp_send(client, "echo: ", 6, false, &errcode);
if (errcode) {
fprintf(stderr, "Error: %s\n", microtcp_strerror(errcode));
goto handled;
}
fprintf(stderr, "(%ld bytes sent 1)\n", sent1);
fprintf(stderr, "(%d bytes sent 1)\n", (int) sent1);
size_t sent2 = microtcp_send(client, buffer, num, false, &errcode);
if (errcode) {
fprintf(stderr, "Error: %s\n", microtcp_strerror(errcode));
goto handled;
}
fprintf(stderr, "(%ld bytes sent 2)\n", sent2);
fprintf(stderr, "(%d bytes sent 2)\n", (int) sent2);
handled:
microtcp_close(client);