172, 5/9 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   han7685
   ¼ÒÄÏÇÁ·Î±×·¡¹Ö ¿À·ùÁ»Ã£¾ÆÁÖ¼¼¿ä~¤Ð

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



#include<sys/socket.h>
#include<sys/stat.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<string.h>
#define MAXBUF 1024

int main(int argc, char **argv)
{
int server_sockfd, client_sockfd;
int client_len, n;
char buf[MAXBUF];
struct sockaddr_in clientaddr, serveraddr;

client_len = sizeof(clientaddr);
if((server_sockfd = socket (AF_INET,SOCK_STREAM, IPPROTO_TCP)) == -1)
{
perror("socket error :");
exit(0);
}


}
bzero(&serveraddr, sizeof(serveraddr));
serveraddr.sin_family = AF_INET;
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
serveraddr.sin_port= htons(atoi(argv[1]));
bind (server_sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
listen(server_sockfd, 5);

while(1)
{
memset(buf,0x00,MAXBUF);
client_sockfd = accept(server_sockfd,
(struct sockaddr *)&clientaddr, &client_len);
printf("NEW Client connect : %s\n", inet_ntoa(clientaddr.sin_addr));
if((n=read(client_sockfd,buf,MAXBUF) <=0))
{
close(client_sockfd);
continue;
}
if(write(client_sockfd,buf,MAXBUF)<=0)
{
perror("write error:");
close(client_sockfd);
}
close(server_sockfd);
return 0;
}
main °ú
19¹ø¤Š¶óÀΠ exit(0)
45¹ø°¶óÀο¡¼­ ¿¡·¯°¡³­µ¥¿ä...
¾Æ¹«¸®ºÁµµ Àú´Â¸øã°Ú³×¿©...


  Hit : 3317     Date : 2012/11/19 10:55



    
º¸¾È¿Õ Ŭ¶óÀ̾ðÆ® sockÀ» Á¤ÇØÁÖ´Â clientlenÀ» intŸÀÔÀÌ ¾Æ´Ï¶ó socklen_t ÀÌ°Å¿´³ª ÀÌ Å¸ÀÔÀ¸·Î ÇØÁÖ¼¼¿ä. Ã¥¿¡ ±× ºÎºÐ º¸½Ã¸é µÉ°Å¿¡¿ä. 2012/11/21  
cd80 mainÇÔ¼ö¿¡¼­ »ç¿ëµÈ if¹®À» º¸½Ã¸é
if((server_sockfd = socket (AF_INET,SOCK_STREAM, IPPROTO_TCP)) == -1)
{
perror("socket error :");
exit(0);
}


}

ÀÌ·¸°Ô µÅÀִµ¥
if¹®À» ³¡³½ } ´ÙÀ½¿¡ ÀÖ´Â } ¶§¹®¿¡ ¿¡·¯°¡ ³³´Ï´Ù
2012/11/21  
92   ¿ÜºÎ¿Í ³×Æ®¿÷ÀÌ µÇ´ÂÁö ¾ÈµÇ´ÂÁö È®Àιæ¹ýÀº?[3]     huchik
05/15 3493
91   backtrack 5 ¿¡ ÀÖ´Â ettercap Áú¹®ÀÔ´Ï´Ù.     pk920207
05/09 4116
90   ftp °¡ anonymous·Î ¿­¸°¼­¹ö·Î ħÅõ°¡ °¡´ÉÇÒ±î¿ä???     kavenger
05/01 3231
89   ¹éÆ®·¢ ½Ç½À¿ë USB ·£Ä«µå ÃßÀü ºÎŹµå¸³´Ï´Ù.[2]     ifocean
04/16 5233
88   mylg070 º¸¾È¼³Á¤ Áú¹®.     ien0l5uf
04/16 4454
87   UDP Flooding ¹æ¾î±â¹ý.     stares
04/14 4626
86   ³×Æ®¿öÅ© ÇØÅ·À» À§Çؼ­ ÇÊ¿äÇÑ ±âÃÊ°¡ ¹«¾ùÀÌÁÒ?[3]     hansu9911
04/01 3855
85   ¿ÜºÎÄÄÇ»ÅÍ Á¢¼Ó[1]     choisunho
02/27 3830
84   ¿ìºÐÅõ wpa/wpa2 handshake ¼ø°£ÀÌ!!![1]     pass-3-
02/27 3786
83   ÇØÅ·À» À§ÇÑ ³×Æ®¿öÅ©¿¡ ´ëÇØ °³³äÀ» Àâ°í½Í½À´Ï´Ù[1]     rowel
02/17 3106
82   SQL ÀÎÁ§¼Ç Áú¹®ÀÌ¿ä!!!![1]     skrillex
01/22 3128
81   ³×Æ®¿öÅ© ¶ó¿ìÅÍÀÇ ±â´É[1]     woals3006
12/24 3477
80   NC¼ÒÇÁÆ®¸¦ »ó´ë·Î ¼Ò¼Û ÁغñÁß¿¡ ÀÖ½À´Ï´Ù.[1]     TOGEACE
12/09 3801
  ¼ÒÄÏÇÁ·Î±×·¡¹Ö ¿À·ùÁ»Ã£¾ÆÁÖ¼¼¿ä~¤Ð[2]     han7685
11/19 3316
78   ³×Æ®¿öÅ© ¼­Àû ¹× Áøµµ°ü·Ã..[1]     ISHack
11/02 3289
77   Network ±âº»ÀûÀÎ?     ISHack
10/29 2966
76   vmWare¸¸ °¡Áö°í ³×Æ®¿öÅ© ÇØÅ· ¿¬½ÀÀ» ÇÒ ¼ö ÀÖ³ª¿ä??[1]     darkofgy
10/13 3787
75   °©Àڱ⠰øºÎÇÏ´Ù°¡ ±Ã±ÝÇÑ°Ô »ý°Ü¼­ ±Û¿Ã¸³´Ï´Ù     hyde0401
09/09 3285
74   IPFW°ü·Ã Áú¹®ÀÔ´Ï´Ù!!!     4class
09/06 2942
73   ¼ÒÄÏ ÇÁ·Î±×·¡¹Ö~??[2]     dreadlo
09/05 3711
[1][2][3][4] 5 [6][7][8][9]

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