Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <arpa/inet.h>
- #include <net/ethernet.h>
- #include <errno.h>
- #include <time.h>
- #define SOCK_LIMIT1 5000
- #define SOCK_LIMIT2 10000
- /* Total number of sockets is (SOCK_LIMIT1 * SOCK_LIMIT2) */
- int main (int argc, char **argv)
- {
- int i, j, sd;
- double secs = 0.0;
- for(i = 0; i < SOCK_LIMIT1; ++i)
- for(j = 0; j < SOCK_LIMIT2; ++j) {
- /* Submit request for a raw socket descriptor */
- if ((sd = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL))) < 0) {
- perror ("socket() failed ");
- exit (EXIT_FAILURE);
- }
- clock_t start = clock();
- /* Close socket descriptor */
- close (sd);
- secs += (double)(clock() - start) / (double) CLOCKS_PER_SEC;
- }
- printf("Sock closing time (secs): %.2f\n", secs);
- return (EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement