SHARE
TWEET

Untitled

a guest Aug 15th, 2012 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <arpa/inet.h>
  2. #include <netinet/in.h>
  3. #include <sys/types.h>
  4. #include <sys/socket.h>
  5. #include <err.h>
  6. #include <errno.h>
  7. #include <strings.h>
  8. #include <stdlib.h>
  9. #include <unistd.h>
  10.  
  11. int
  12. main(void)
  13. {
  14.         int s;
  15.         struct sockaddr_in name;
  16.         socklen_t len;
  17.  
  18.         bzero(&name, sizeof(name));
  19.         name.sin_family = AF_INET;
  20.         name.sin_port = htons(55555);
  21.         name.sin_addr.s_addr = inet_addr("127.0.0.1");
  22.         len = sizeof(name);
  23.         for ( ;; ) {
  24.                 s = socket(AF_INET, SOCK_STREAM, 0);
  25.                 if (s == -1)
  26.                         err(1, "socket");
  27.                 if (connect(s, (const struct sockaddr *)&name, len) == -1) {
  28.                         if (errno != ECONNREFUSED)
  29.                                 err(1, "connect");
  30.                 } else {
  31.                         warnx("connected");
  32.                         pause();
  33.                 }
  34.                 close(s);
  35.         }
  36.  
  37.         exit(0);
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top