This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Create server.py
Abdul Wahab Junaid12f4bdd85da7
diff --git a/Python Tools/Socket_Modules/server.py b/Python Tools/Socket_Modules/server.pynew file mode 100644index 0000000..0a32a0b--- /dev/null+++ b/Python Tools/Socket_Modules/server.py@@ -0,0 +1,46 @@+import socketio+import aiohttp+import asyncio++# Create a new Socket.IO server instance with asyncio support+sio = socketio.AsyncServer(async_mode='aiohttp')++# Create an aiohttp web application+app = aiohttp.web.Application()+sio.attach(app)++# Define an event handler for the 'connect' event+async def connect(sid, environ):+ print(f"Client connected: {sid}")++# Define an event handler for the 'message' event+async def message(sid, data):+ print(f"Message from {sid}: {data}")+ # Broadcast the received message to all connected clients+ await sio.emit('response', {'data': f"Server received: {data}"}, room=sid)++# Define an event handler for the 'disconnect' event+async def disconnect(sid):+ print(f"Client disconnected: {sid}")++if __name__ == '__main__':+ # Start the server on port 5000+ web_runner = aiohttp.web.AppRunner(app)+ loop = asyncio.get_event_loop()++ try:+ loop.run_until_complete(web_runner.setup())+ loop.run_until_complete(+ aiohttp.web.TCPSite(+ web_runner, 'localhost', 5000+ ).start()+ )+ print("Server running on http://localhost:5000")+ loop.run_forever()+ except KeyboardInterrupt:+ pass+ finally:+ loop.run_until_complete(web_runner.cleanup())