printf("Timed out, %d/%d bytes sent.\n", result, size);
/* Allocate a buffer to receive data. */
- char buf[size + 1];
+ char *buf = malloc(size + 1);
/* Try to receive the data on the other port. */
printf("Receiving %d bytes on port %s.\n",
/* Check if we received the same data we sent. */
buf[result] = '\0';
printf("Received '%s'.\n", buf);
+
+ /* Free receive buffer. */
+ free(buf);
}
/* Close ports and free resources. */