Skip to content

Instantly share code, notes, and snippets.

View jollyreal's full-sized avatar

TOK CHANG WENN jollyreal

View GitHub Profile
@jollyreal
jollyreal / concurrent_udp_client.py
Created May 4, 2021 12:32
use the concurrent module to execute the UDP request
import socket
import select
import time
from concurrent import futures
def udp_request(src_ip,src_port,dst_ip,dst_port):
'''send an UDP packet that contain a string of "hello" to the dst_ip:dst_port from src_ip:src_port'''
# create the request socket
request_socket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
request_socket.bind((src_ip,src_port))
@jollyreal
jollyreal / UDP_servers.py
Created May 4, 2021 12:01
An UDP server that listen to 100 ports and give response when those ports received any UDP packet.
import socket
import select
if __name__ == "__main__":
# constant of program
IP_ADDRESS = "192.168.11.10"
PORT_NO_START = 10024
PORT_NO_END = 10124
# the payload that UDP server will response