IPv6변환을 위해 연습 했던 소스


1.1 IPv4 클라이언트 소스

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>

#define BUFSIZE 1024

void error_handling(char *);

void

error_handling(char *message)

{
fputs(message, stderr);
fputc('\n', stderr);       
exit(1);
}

int main (int argc, char *argv[])
{
       int sock;
       struct sockaddr_in serv_addr;

    

       char message[BUFSIZE];
       int len;
       int add;

       if (argc != 3) {
       printf("usage : %s <server's IP> <port>\n", argv[0]);
       exit(1);
}

       sock = socket(PF_INET, SOCK_STREAM, 0);
       if (sock == -1)
       error_handling("socket() error");

       memset(&serv_addr, 0, sizeof(serv_addr));
       serv_addr.sin_family = AF_INET;
       serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
       serv_addr.sin_port = htons(atoi(argv[2]));

        if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
               error_handling("accept() error");

       while (1)
       {      
               fputs("\nInput number to send(q to quit) : ", stdout);
               fgets(message, BUFSIZE, stdin);

               if (!strcmp(message, "q\n"))
                       break;

               write(sock, message, strlen(message));

               len = read(sock, message, BUFSIZE-1);
               message[len] = 0;

               printf("Added Number from Server : %s\n", message);
}

       close(sock);
       return 0;

       }

1.2 IPv4 서버

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BUFSIZE 1024

void error_handling(char *);

void

error_handling(char *message)

{
fputs(message, stderr);
fputc('\n', stderr);       
exit(1);
}

int main (int argc, char *argv[])
{
       int serv_sock, clnt_sock;
       struct sockaddr_in serv_addr, clnt_addr;

       int clnt_addr_size;

       char message[BUFSIZE];
       int len;
       int add;

       if (argc != 2) {
       printf("usage : %s <port>\n", argv[0]);
       exit(1);
}

       serv_sock = socket(PF_INET, SOCK_STREAM, 0);
       if (serv_sock == -1)
       error_handling("socket() error");

        memset(&serv_addr, 0, sizeof(serv_addr));
       serv_addr.sin_family = AF_INET;
       serv_addr.sin_addr.s_addr = inet_addr("10.51.12.166");
       serv_addr.sin_port = htons(atoi(argv[1]));

       if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
       error_handling("bind() error");

       if (listen(serv_sock, 5) == -1 )
       error_handling("listen() error");

       printf("server started!!(%s)\n", argv[1]);

       clnt_addr_size = sizeof(clnt_addr);
       clnt_sock = accept(serv_sock, (struct sockaddr *)&clnt_addr,&clnt_addr_size);
       if (clnt_sock == -1)
       error_handling("accept() error");

       printf("clnt connected!!(%s:%d)\n",
       inet_ntoa(clnt_addr.sin_addr), clnt_addr.sin_port);

       int buf=0;
       while ((len = read(clnt_sock, message, BUFSIZE)) != 0) {
      
               buf+=atoi(message);
               sprintf(message, "%d", buf);
               len = strlen(message);
               write(clnt_sock, message, len);
       }

       printf("server terminated\n");

       close(clnt_sock);

       return 0;

}

2.1 IPv6 클라이언트

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>

#define BUFSIZE 1024

void error_handling(char *);

void

error_handling(char *message)

{
fputs(message, stderr);
fputc('\n', stderr);       
exit(1);
}

int main (int argc, char *argv[])
{
       int sock;
       struct sockaddr_in6 serv_addr;

    

       char message[BUFSIZE];
       int len;
       int add;

       if (argc != 3) {
       printf("usage : %s <server's IP> <port>\n", argv[0]);
       exit(1);
}

       sock = socket(PF_INET6, SOCK_STREAM, 0);
       if (sock == -1)
       error_handling("socket() error");

       memset(&serv_addr, 0, sizeof(serv_addr));
       serv_addr.sin6_family = AF_INET6;
       serv_addr.sin6_addr = in6addr_any;
       serv_addr.sin6_port = htons(atoi(argv[2]));

        if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
               error_handling("accept() error");

       while (1)
       {      
               fputs("\nInput number to send(q to quit) : ", stdout);
               fgets(message, BUFSIZE, stdin);

               if (!strcmp(message, "q\n"))
                       break;

               write(sock, message, strlen(message));

               len = read(sock, message, BUFSIZE-1);
               message[len] = 0;

               printf("Added Number from Server : %s\n", message);
}

       close(sock);
       return 0;

       }



2.2 IPv6서버

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BUFSIZE 1024

void error_handling(char *);

void

error_handling(char *message)

{
fputs(message, stderr);
fputc('\n', stderr);       
exit(1);
}

int main (int argc, char *argv[])
{
       int serv_sock, clnt_sock;
       struct sockaddr_in6 serv_addr, clnt_addr;

       int clnt_addr_size;

       char message[BUFSIZE];
       int len;
       int add;

       if (argc != 2) {
       printf("usage : %s <port>\n", argv[0]);
       exit(1);
}

       serv_sock = socket(PF_INET6, SOCK_STREAM, 0);
       if (serv_sock == -1)
       error_handling("socket() error");

        memset(&serv_addr, 0, sizeof(serv_addr));
       serv_addr.sin6_family = AF_INET6;
       serv_addr.sin6_flowinfo = 0;
       serv_addr.sin6_addr = in6addr_any;
       serv_addr.sin6_port = htons(atoi(argv[1]));

       if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
       error_handling("bind() error");

       if (listen(serv_sock, 5) == -1 )
       error_handling("listen() error");

       printf("\nserver started!!(%s)\n", argv[1]);

       clnt_addr_size = sizeof(clnt_addr);
       clnt_sock = accept(serv_sock, (struct sockaddr *)&clnt_addr,&clnt_addr_size);
       if (clnt_sock == -1)
       error_handling("accept() error");

       printf("\nclnt connected!!\n"
       );

       int buf=0;
       while ((len = read(clnt_sock, message, BUFSIZE)) != 0) {
      
               buf+=atoi(message);
               sprintf(message, "%d", buf);
               len = strlen(message);
               write(clnt_sock, message, len);
       }

       printf("\nserver terminated!!!\n");

       close(clnt_sock);

       return 0;

}




작성일 : 2006.07.14
작성자 : 임헌정
http://www.4ellene.net

2006/07/14 15:55 2006/07/14 15:55
Trackback address :: http://4ellene.net/tt/trackback/977
  1. casino games

    Tracked from casinos 2009/03/30 16:15  삭제

    no deposit online casino

  2. herbal viagra

    Tracked from viagra cialis levitra 2009/04/02 17:38  삭제

    non prescription viagra

  3. Tracked from rape comics 2009/04/13 05:24  삭제

    rape club

  4. Tracked from girl forced sex 2009/04/13 11:46  삭제

    gay forced sex

  5. dildo rape

    Tracked from doctor rape 2009/04/14 11:16  삭제

    daughter rape porn

  6. bdsm cartoons

    Tracked from bdsm clips 2009/04/14 21:54  삭제

    bdsm cafe

  7. gangbang rape

    Tracked from rape scene in porn 2009/06/29 07:06  삭제

    rape video

  8. rape in movies

    Tracked from brother sister rape 2009/06/29 19:03  삭제

    incest rape

  9. brutal blow jobs

    Tracked from rape fantasies 2009/06/29 20:04  삭제

    rape comics

  10. photos of drunk rape women

    Tracked from forced to fuck 2009/06/30 12:12  삭제

    rape insest porn top

  11. rape films

    Tracked from girl forced sex 2009/06/30 19:23  삭제

    illegal rape

  12. porn rape videos

    Tracked from teen rapes 2009/06/30 22:23  삭제

    movies with rape

  13. brutal fuck

    Tracked from lesbian rape stories 2009/07/01 06:10  삭제

    extreme anal fucking

  14. lesbian forced sex

    Tracked from father rape 2009/07/01 06:54  삭제

    rape tales

  15. rape incest porn

    Tracked from extreme anal fucking 2009/07/01 07:09  삭제

    blonde rape

  16. doctor rape

    Tracked from femdom rape 2009/07/01 14:05  삭제

    rape pictures stories

  17. doctor rape

    Tracked from max hardcore extreme 2009/07/01 21:40  삭제

    rape poems

  18. virgin rape porn

    Tracked from story rape 2009/07/02 00:53  삭제

    prison rape

  19. rape sites

    Tracked from gang rape videos 2009/07/02 02:13  삭제

    porno rape

  20. forced oral sex

    Tracked from hentai rape 2009/07/02 08:47  삭제

    rape sex videos

  21. rape videos

    Tracked from rape scene 2009/07/02 11:32  삭제

    porn hawaiian rape

  22. mother rape

    Tracked from rape torture 2009/07/03 04:32  삭제

    rape galleries

  23. rape index porn

    Tracked from mother rapes son 2009/07/03 05:49  삭제

    forced bondage

  24. rape cases

    Tracked from dog rape 2009/07/03 10:27  삭제

    rape porn

  25. drunk rape

    Tracked from extreme porn 2009/07/03 12:32  삭제

    sexy rape

  26. story rape

    Tracked from mature forced sex 2009/07/04 02:45  삭제

    rape tube

  27. bizarre extreme sex

    Tracked from brutal facesitting 2009/07/04 17:50  삭제

    extreme cumshots

  28. rape cartoons

    Tracked from father rapes daughter 2009/07/04 18:40  삭제

    rape hentai

  29. rape thumbs

    Tracked from rape tales 2009/07/05 14:24  삭제

    nurse rape

  30. fake rape

    Tracked from real rape videos 2009/07/06 03:56  삭제

    outdoor rape

  31. rape drawings

    Tracked from rape poems 2009/07/06 22:24  삭제

    forced sex reporter

  32. forced womanhood stories

    Tracked from iraqi rape 2009/07/07 08:54  삭제

    fantasy forced sex

  33. casino games http

    Tracked from england casino 2009/07/10 19:23  삭제

    uk online casinos

  34. online casinos for us players

    Tracked from online casino deposit 2009/07/11 02:05  삭제

    online casino game

  35. online casino free bonus

    Tracked from casinos online 2009/07/11 03:26  삭제

    best online casino

  36. play poker online

    Tracked from casino gambling online 2009/07/11 03:42  삭제

    online gambling casinos

  37. internet casino online

    Tracked from golden casino http 2009/07/11 12:29  삭제

    casino gaming online

  38. reliable online casinos

    Tracked from online download casino games blackjack 2009/07/11 18:10  삭제

    casinos online

  39. play poker online

    Tracked from casino party usa 2009/07/12 20:39  삭제

    casino free online

  40. casinos gratis online

    Tracked from free online casino games 2009/07/13 00:04  삭제

    usa accepting casinos

  41. top ten online casinos

    Tracked from free online casino 2009/07/13 13:17  삭제

    online casinos for us players

  42. free online casinos

    Tracked from casino games online 2009/07/13 17:59  삭제

    casino wagering

  43. online casino game

    Tracked from play casino games online 2009/07/14 16:05  삭제

    casino on the net

  44. casinos gratis online

    Tracked from free online casino cash 2009/07/14 20:01  삭제

    us friendly casinos

  45. usa online casino

    Tracked from online casino no deposit 2009/07/14 22:32  삭제

    online casino usa

  46. online casino blackjack

    Tracked from no deposit online casino 2009/07/15 00:19  삭제

    england casino

  47. download online casino games

    Tracked from online casino no depost 2009/07/15 12:29  삭제

    online kasino

  48. free online casino games

    Tracked from beating online casinos 2009/07/16 09:31  삭제

    play for fun online casino

  49. play casino games online

    Tracked from no deposit online casino listings usa 2009/07/16 18:53  삭제

    casino http

  50. poker games online

    Tracked from list of online casinos 2009/07/17 05:58  삭제

    free online casino

  51. online kasino

    Tracked from casinos online internet 2009/07/17 06:14  삭제

    casino website

  52. online gambling casino

    Tracked from online casinos no deposit bonuses 2009/07/19 02:23  삭제

    new online casino

  53. international online casinos

    Tracked from best online casino 2009/07/19 11:03  삭제

    casinos http

  54. casino supplies

    Tracked from java internet casino 2009/07/19 11:37  삭제

    free online casino slots

  55. transexual escort london

    Tracked from big tits transexuals 2009/07/20 06:00  삭제

    extreme ladyboys

  56. transexual porn

    Tracked from transvestite chat 2009/07/21 03:08  삭제

    young transsexual

  57. trannies in trouble

    Tracked from shemale strokers 2009/07/21 11:35  삭제

    beautiful transexuals

  58. futanari video

    Tracked from shemale pictures 2009/07/21 18:27  삭제

    shemale creampie

  59. transexual pictures

    Tracked from post op transsexuals 2009/07/22 04:24  삭제

    shemales cumming

  60. shemale gallery

    Tracked from teen ladyboys 2009/07/22 10:42  삭제

    black transsexual

  61. young transsexual

    Tracked from tranny orgy 2009/07/22 14:18  삭제

    asian ladyboys dp

  62. ladyboys in pantyhose

    Tracked from tranny threesome 2009/07/23 06:33  삭제

    hot transexuals

  63. transexual dating

    Tracked from doujinshi futanari 2009/07/23 11:36  삭제

    transvestite tube

  64. blonde ladyboy

    Tracked from transexual movies 2009/07/23 19:13  삭제

    shemale vanity

  65. shemale hentai

    Tracked from black ladyboys 2009/07/24 05:06  삭제

    amateur transvestite

  66. ladyboy vids

    Tracked from chinese ladyboys 2009/07/24 16:12  삭제

    dickgirl futanari

  67. tranny hunter

    Tracked from transsexual porn 2009/07/25 03:08  삭제

    submissive transsexual

  68. ladyboy porn

    Tracked from futanari sex 2009/07/25 06:44  삭제

    transgender art and comics

  69. extreme rape porn

    Tracked from forced machine sex 2009/07/25 18:13  삭제

    rape prevention

  70. father daughter porn

    Tracked from father fucks daughter 2009/09/06 05:03  삭제

    incest porn

  71. incest hentai

    Tracked from incest cartoon 2009/09/06 11:56  삭제

    comics incest

  72. incest pics

    Tracked from free incest 2009/09/06 12:40  삭제

    preteen incest

  73. brother sister incest

    Tracked from brother on sister porn 2009/09/06 14:31  삭제

    brother sister sex

  74. amateur incest family porn

    Tracked from incest porn 2009/09/07 06:30  삭제

    free incest porn

  75. Moms Fucking Sons

    Tracked from Fucked Her Son 2009/09/07 07:22  삭제

    Mom And Son Sex Galleries

  76. dad fucking virgin daughter

    Tracked from dad and daughter 2009/09/08 05:41  삭제

    fathers fucking daughters

  77. brother on sister porn

    Tracked from sister fucking brother 2009/09/08 05:49  삭제

    brother and sister sex

  78. dad with sis son sex mom

    Tracked from dad and daughter incest 2009/09/08 13:53  삭제

    dad and daughter

  79. incest porn gallery

    Tracked from free incest porn videos 2009/09/08 21:48  삭제

    mom daughter sex

  80. family nude

    Tracked from family incest galleries 2009/09/08 22:55  삭제

    family nudist galleries

  81. moms fucking sons

    Tracked from mom strips for son 2009/09/09 08:59  삭제

    mother daughter fuck

  82. lesbian incest

    Tracked from incest art 2009/09/09 20:42  삭제

    brother sister incest

  83. bondage blowjob

    Tracked from bondage blog 2009/09/11 02:54  삭제

    bondage clips

  84. bdsm sex movies

    Tracked from bdsm sex 2009/09/12 07:06  삭제

    bdsm sites

  85. torture whip

    Tracked from torture videos 2009/09/12 13:32  삭제

    tranny bdsm

  86. bdsm bound

    Tracked from bdsm books 2009/09/12 13:45  삭제

    bdsm cafe

  87. girls in bondage

    Tracked from girl bondage 2009/09/13 21:46  삭제

    groin torture

  88. bondage movies

    Tracked from bondage movie 2009/09/14 07:20  삭제

    bondage orgasm

  89. enema torture

    Tracked from electro torture 2009/09/14 09:17  삭제

    extreme bdsm

  90. amateur bondage

    Tracked from amateur bdsm free videos 2009/09/14 10:04  삭제

    anal bondage

  91. femdom bondage

    Tracked from femdom bdsm 2009/09/15 13:39  삭제

    feminine domination

  92. bdsm playpen

    Tracked from bdsm pillory 2009/09/15 20:15  삭제

    bdsm sex

  93. bdsm for all

    Tracked from bdsm couples 2009/09/16 15:04  삭제

    bdsm free

  94. sado maso

    Tracked from sado 2009/09/17 15:37  삭제

    sado sex

  95. mother son sex

    Tracked from Mother Sucks Son 2009/09/27 11:35  삭제

    mother son incest

  96. daughter sex

    Tracked from father daughter sex 2009/09/27 12:16  삭제

    daddies fucking daughters

  97. family sex clips

    Tracked from family orgy 2009/09/27 16:51  삭제

    family porn

  98. little sister

    Tracked from lesbian twin sisters 2009/09/28 19:53  삭제

    mom and daughter

  99. dad and daughter

    Tracked from dad and daughter incest 2009/09/28 21:08  삭제

    dad with sis son sex mom

  100. twin sister sex

    Tracked from teen incest 2009/09/29 12:18  삭제

    twin sisters fucking

  101. family incest

    Tracked from family sex 2009/09/29 12:49  삭제

    Family Porn

  102. incest stories

    Tracked from incest sex 2009/10/02 09:50  삭제

    incest pictures

  103. father son sex

    Tracked from father fucks daughter 2009/10/02 10:57  삭제

    fathers fucking daughters

  104. sister fucking brother

    Tracked from simpsons family sex 2009/10/03 13:24  삭제

    sister incest

  105. bdsm cafe

    Tracked from bdsm cartoons 2009/10/20 03:02  삭제

    bdsm clips

  106. bdsm clips

    Tracked from bdsm comics 2009/10/20 08:27  삭제

    bdsm comix

  107. bdsm 666

    Tracked from bdsm anal 2009/10/20 08:51  삭제

    bdsm art

  108. girl bondage

    Tracked from girls in bondage 2009/10/21 09:31  삭제

    hardcore bondage

  109. anime bondage

    Tracked from asian bondage 2009/10/21 16:34  삭제

    bbw bondage

  110. device bondage

    Tracked from diaper bondage 2009/10/22 14:24  삭제

    ebony bondage

  111. lesbian bdsm

    Tracked from male bdsm 2009/10/23 12:48  삭제

    public bdsm

  112. bdsm tube

    Tracked from bdsm video 2009/10/23 18:30  삭제

    bdsm videos

Comments List

Write a comment.

[로그인][오픈아이디란?]