Skip to content

Instantly share code, notes, and snippets.

@jollyreal
jollyreal / concurrent_udp_client.py
Created May 4, 2021
use the concurrent module to execute the UDP request
View concurrent_udp_client.py
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
An UDP server that listen to 100 ports and give response when those ports received any UDP packet.
View UDP_servers.py
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