1588, 76/80 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   ÇØÅ·ÀßÇÏ°í½Í´Ù
   http://¾øÀ½
   python.png (147.9 KB), Download : 0     [¿À¸¥ÂÊ ¹öÆ° ´­·¯ ´Ù¿î ¹Þ±â]
   image_(1).png (99.8 KB), Download : 0     [¿À¸¥ÂÊ ¹öÆ° ´­·¯ ´Ù¿î ¹Þ±â]
   ÆÄÀ̽ã äÆà ÇÁ·Î±×·¥ ±¸Çö

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




Ŭ¶óÀ̾ðÆ® ±¸Çö

¼­¹ö¿¡ µ¥ÀÌÅ͸¦ ÁÖ°í ¹Þ±â À§ÇØ ¼ÒÄÏ ¿¬°á ¿äûÀ» ÇÏ´Â ÃøÀ¸·Î
IP¿Í Æ÷Æ®¹øÈ£·Î ¼­¹ö¿¡ ¿¬°áÀ» ¿äûÇÑ´Ù.


ÄÚµå ¿¹Á¦¸¦ º¸±â ÀÌÀü¿¡ setsockopt ¸Þ¼Òµå¿¡ ´ëÇØ ¾Ë¾Æº¸°Ú´Ù.



---------------------------------------------------------------
socket.setsockopt(level, optname, None, optlen: int)

Set the value of the given socket option (see the Unix manual page setsockopt(2)).
The needed symbolic constants are defined in this module
(SO_* etc. <socket-unix-constants>).
The value can be an integer,
None or a bytes-like object representing a buffer.
In the later case it is up to the caller to ensure
that the bytestring contains the proper bits
(see the optional built-in module struct for a way to encode C structures as bytestrings).
When value is set to None, optlen argument is required.
It¡¯s equivalent to call setsockopt() C function with optval=NULL and optlen=optlen.


Çؼ®

ÁÖ¾îÁø ¼ÒÄÏ ¿É¼ÇÀÇ °ªÀ» ¼³Á¤ÇÕ´Ï´Ù. ÇÊ¿äÇÑ »ó¼ö´Â ÀÌ ¸ðµâ¿¡¼­ Á¤Àǵ˴ϴÙ
SO_* µî, <socket-unix-constants>¸¦ ÂüÁ¶Çϼ¼¿ä).
°ªÀº Á¤¼ö, None ¶Ç´Â ¹öÆÛ¸¦ ³ªÅ¸³»´Â ¹ÙÀÌÆ®·ù °´Ã¼ÀÏ ¼ö ÀÖ½À´Ï´Ù.
ÈÄÀÚÀÇ °æ¿ì È£ÃâÀÚ°¡ ¿Ã¹Ù¸¥ ºñÆ®¸¦ Æ÷ÇÔÇÏ´ÂÁö È®ÀÎÇØ¾ß ÇÕ´Ï´Ù
(¿É¼ÇÀ¸·Î ³»Àå ¸ðµâ struct¸¦ »ç¿ëÇÏ¿© C ±¸Á¶Ã¼¸¦ ¹ÙÀÌÆ®¿­·Î ÀÎÄÚµùÇÏ´Â ¹æ¹ýÀ» ÂüÁ¶Çϼ¼¿ä).
°ªÀÌ NoneÀ¸·Î ¼³Á¤µÈ °æ¿ì optlen Àμö°¡ ÇÊ¿äÇÕ´Ï´Ù.
ÀÌ°ÍÀº optval=NULL ¹× optlen=optlenÀ¸·Î setsockopt() C ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °Í°ú µ¿µîÇÕ´Ï´Ù.
-----------------------------------------------------------------
ÀÚ¼¼ÇÑ °Ç ¾Æ·¡ÀÇ ¸µÅ©·Î...
https://docs.python.org/ko/3.10/library/socket.html









Ŭ¶óÀ̾ðÆ® Ãø ¼Ò½º

import socket

server_host = 127.0.0.1 # Loopback IP
server_port = 44444

client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

#connect to server
client_sock.connect((server_host, server_port))
print(f'Server: {server_host}, {server_port} connect nomally')

while True:
    message = input(">>> ")
    client_sock.sendall(message.encode('utf-8'))
    message = client_sock.recv(1024)
    print(f"server: {message.decode()}")
client_sock.close()



¼­¹ö ±¸Çö & ¼­¹ö Ãø ¼Ò½º

import socket

host = '127.0.0.1'
port = 44444

parent_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
parent_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

parent_sock.bind((host, port))
parent_sock.listen(5)
print(f'Server IP: {host}, Port Num: {port} excuting to server...')

child_sock, child_addr = parent_sock.accept()
print(f'accept from {child_addr}')

while True:
    message = child_sock.recv(1024)
    print(f'{child_addr}: {message.decode()}')
    child_sock.sendall(message)

child_sock.close()
parent_sock.close()

  Hit : 553     Date : 2024/05/28 11:45



    
88   levitator.c (¾Èµå·ÎÀÌµå ·çÆÃ) °ø°Ý ºÐ¼® ¼Ò½º ÄÚµå °øÀ¯.[4]     scube
08/17 4177
87   ¾È³çÇϼ¼¿ä.     god0631a
03/16 3962
86   ±¸±Û ¹é¸µÅ© ÀÛ¾÷ Áú¹®¿ä     wkatnxka
03/30 3829
85   ½©ÄÚµå ¸ðÀ½     ÇØÅ·ÀßÇÏ°í½Í´Ù
01/15 2048
84   (²Ä¼ö) L.O.B Çѹ濡 Ŭ¸®¾îÇϱâ[2]     ÇØÅ·ÀßÇÏ°í½Í´Ù
01/14 1796
83   Call by value VS Call by Reference     ÇØÅ·ÀßÇÏ°í½Í´Ù
01/15 1397
82   ¸®´ª½º Ä¿³Î 2.6 ¹öÀü ÀÌÈÄÀÇ LKM     jdo
07/25 1209
81   °í¼ö´ÔµéÀÇ µµ¿òÀ» ¹Þ°í ½Í½À´Ï´Ù     vbnm111
02/11 688
80   ÆÄÀ̽ã random¸ðµâÀ» ÀÌ¿ëÇÑ ¼ýÀÚ¸ÂÃ߱⠰ÔÀÓ ±¸Çö     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/30 640
79   ÆÄÀ̽㠼ÒÄÏ ÇÁ·Î±×·¡¹ÖÀÇ ±âÃÊ     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/26 576
  ÆÄÀ̽ã äÆà ÇÁ·Î±×·¥ ±¸Çö     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/28 552
77   ¸®´ª½º/À©µµ¿ì º¸¾È Àåºñ ·Î±×     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/20 541
76   ¸®´ª½º À¥ ·Î±× ºÐ¼®     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/20 436
75   netdiscover ÆÄÀ̽ãÀ¸·Î ±¸ÇöÇϱ⠠   ÇØÅ·ÀßÇÏ°í½Í´Ù
08/13 156
74   ÆÄÀ̽ãÀ» ÀÌ¿ëÇÑ ½ÉÇà À¥ Å©·Ñ·¯     ÇØÅ·ÀßÇÏ°í½Í´Ù
08/13 128
73 ºñ¹Ð±ÛÀÔ´Ï´Ù  °¨À»¸øÀâ°Ú³×¿ä¤Ì¤Ì     À×À×À×
01/15 3
72 ºñ¹Ð±ÛÀÔ´Ï´Ù  2.3 ¸ð´ÏÅÍ¿¡ µ¥ÀÌÅÍ Ãâ·ÂÇϱâ printf()      xownsdk2
08/20 2
71 ºñ¹Ð±ÛÀÔ´Ï´Ù  ÇØÄ¿½ºÄð °ü¸®ÀÚ´Ô²²     packer
03/20 2
70 ºñ¹Ð±ÛÀÔ´Ï´Ù  Áú¹®ÇÕ´Ï´Ù~     ¸¶´©¶ó
08/05 1
69 ºñ¹Ð±ÛÀÔ´Ï´Ù  [re] : ÇØÄ𠱤ÁÖ¿¡¼­ °°ÀÌ °ÏºÎÇϽǺР¼±»ý´Ô & ½º½Â ±¸ÇÕ´Ï´Ù.     ne4760
03/25 1
[1]..[71][72][73][74][75] 76 [77][78][79][80]

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