172, 7/9 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   dreadlo
   ¼ÒÄÏ ÇÁ·Î±×·¡¹Ö~??

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_Network&no=94 [º¹»ç]


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
void error_handling(char *message);

int main(int argc, char *argv[])
{
        int serv_sock;
        int clnt_sock;

        struct sockaddr_in serv_addr;
        struct sockaddr_in clnt_addr;
        socklen_t clnt_addr_size;

        char message[]="Hello World!";

        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=htonl(INADDR_ANY);
        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!");

        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!");

        write(clnt_sock, message, sizeof(message));
        close(clnt_sock);
        close(serv_sock);
        return 0;
}

void error_handling(char *message)
{
        fputs(message, stderr);
        fputc('\n', stderr);
        exit(1);
}




---------------------------------------------------------------------------------------------------------
¸®´ª½º¿¡¼­ ¼­¹ö¸¦ ½ÇÇàÇÏ·Á´Âµ¥


bind error  ÀÚ²Ù ³ª³×¿ä


¾Æ¹«¸® ã¾ÆºÁµµ ¹®Á¦Á¡ÀÌ ¾ø´Âµ¥ ¤Ì.¤Ì

gcc -o hserver hello_server.c      <- ÀÌ·¸°Ô ÄÄÆÄÀÏÇؼ­
./hserver 9190                         <- Æ÷Æ®¹øÈ£ Àû¾î¼­ ½ÇÇàÇߴµ¥;;;
bind() error!


¸î½Ã°£Â° Çì¸Å³×¿ä ¤Ð.¤Ð

  Hit : 3519     Date : 2012/09/05 10:26



    
phillip474 Ȥ½Ã 9190Æ÷Æ®¸¦ »ç¿ëÇÏ°í ÀÖ´Â°Ô ¾Æ´Ò±î¿ä....
ÇãÁ¢ÀÇ ÂªÀº »ý°¢ÀÔ´Ï´Ù.
2012/09/06  
dreadlo ±×·¡¼­ ´Ù¸¥ Æ÷Æ®¸¦ ½áºÁµµ ... ¤Ì.¤Ì 2012/09/07  
52   °øÀÎ ÁÖ¼Ò ¹èÁ¤?     h@cking2013
02/12 2621
51   °øÀ¯±â¿Í ¶ó¿ìÅÍ?[3]     h@cking2013
02/11 3382
50   À§Ä¡ÃßÀû(?)...........[2]     h@cking2013
03/09 3207
49   ¸ðµ©?[1]     h@cking2013
05/22 2914
48   warning.or.kr!!![2]     h@cking2013
07/04 4125
47   ÇØÅ·°ü·Ã Áú¹®ÀÖ½À´Ï´Ù.     h0j8p9
07/15 2634
46   °°Àº ³×Æ®¿öÅ© »ó¿¡¼­ pcÇØÅ·Àº ¾î¶»°Ô Çϳª¿ä??[2]     h0j8p9
06/30 3863
45   ¡ßÃ౸ÅäÅä,½ºº¸ºª,¡Ú 777betd.COM ¡Ú¾ÆÀ̺ñ¾¾ºª,Çؿܹè´ç¡ß     gwanpo4048
03/17 2644
44   n150u ¹éÆ®·¢5 ¸ð´ÏÅ͸ðµåÁö¿øµÇ³ª¿ä?     gusdlrsla
04/01 3070
43   ³×Æ®¿öÅ© º¸¾È ÀÎÇÁ¶ó ±¸Ãà »ç·Ê[1]     goldbear564
06/30 2842
42   Ä£±¸ÇÑÅ× ping ³¯·È´Âµ¥¿ä.[6]     furscar
04/02 4720
41   ÀÎÅÍ³Ý ·Î±×¿¡ °üÇÏ¿© Áú¹®µå¸³´Ï´Ù     eletsinghua
10/01 2903
40   µðµµ½º¹æ¾î¸¦ ¼³Á¤Çß½À´Ï´Ù. ÀßµÈ°Í ¸Â³ª¿ä?     eastgm
02/07 3301
39   °­Á¦¿ø°Ý °Å´Â¹æ¹ý[11]     dydakdb123
06/11 7881
38   ³×Æ®¿öÅ© ÇØÅ·¿¡¼­..[1]     dwdwzzz
03/23 3057
37   arp spoofingÀÇ ÇÑ°è[2]     dwdwzzz
03/24 3273
  ¼ÒÄÏ ÇÁ·Î±×·¡¹Ö~??[2]     dreadlo
09/05 3518
35   ferret toolÀÌ ¾ø³×¿ä..[1]     dowkrlck
07/21 3276
34   °í¼ö´ÔµéÀÇ µµ¿òÁ» ¹Þ°í ½Í½À´Ï´Ù.......     dosan1590
02/11 2727
33   ¿ÜºÎ ¾ÆÀÌÇÇ·Î ÇØÅ· ÇÏ·Á¸é..?[1]     dolpin1402
04/05 4438
[1][2][3][4][5][6] 7 [8][9]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org