差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
python:socket:programming [2020/05/31 02:16] – ともやん | python:socket:programming [2021/06/25 15:48] (現在) – ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
- | < | ||
- | < | ||
- | #result pre, #mincode pre { | ||
- | overflow: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | # | ||
- | height: 250px; | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | #mintbl table { | ||
- | font-size: 12px; | ||
- | } | ||
- | #mintbl td pre { | ||
- | margin: 0; | ||
- | } | ||
- | #img_long { | ||
- | height: 400px; | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | } | ||
- | .dokuwiki .plugin_wrap table { | ||
- | width: auto; | ||
- | } | ||
- | #logo { | ||
- | background-color: | ||
- | padding: 10px; | ||
- | width: fit-content; | ||
- | } | ||
- | #logo p { | ||
- | margin: 0; | ||
- | } | ||
- | </ | ||
- | </ | ||
====== Python ソケット プログラミング ====== | ====== Python ソケット プログラミング ====== | ||
行 49: | 行 13: | ||
from traceback import print_exc | from traceback import print_exc | ||
- | DEFAULT_PORT = 7 | + | DEFAULT_PORT = 7 # 7 or 9 or 30000 ? |
+ | # | ||
+ | BROADCAST_IPADDR = ' | ||
def send_magic_packet(mac_addr, | def send_magic_packet(mac_addr, | ||
行 56: | 行 22: | ||
sock.setsockopt(socket.SOL_SOCKET, | sock.setsockopt(socket.SOL_SOCKET, | ||
# parse address | # parse address | ||
- | | + | |
- | wol_mac = mac_addr.replace(' | + | |
if len(wol_mac) != 12: | if len(wol_mac) != 12: | ||
raise Exception(' | raise Exception(' | ||
行 68: | 行 33: | ||
# send magic packet | # send magic packet | ||
print(' | print(' | ||
- | sock.sendto(magic_packet, | + | sock.sendto(magic_packet, |
def parse_args(): | def parse_args(): | ||
parser = argparse.ArgumentParser() | parser = argparse.ArgumentParser() | ||
parser.add_argument(' | parser.add_argument(' | ||
- | parser.add_argument(' | + | parser.add_argument(' |
help=' | help=' | ||
default=DEFAULT_PORT, | default=DEFAULT_PORT, | ||
行 84: | 行 49: | ||
try: | try: | ||
+ | #mac_addr = " | ||
send_magic_packet(mac_addr, | send_magic_packet(mac_addr, | ||
行 141: | 行 107: | ||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
+ | [[http:// | ||
+ | [[https:// | ||