troubleshooting Question

convert Python script to C#

Avatar of websss
websssFlag for Kenya asked on
2 Comments1 Solution39 ViewsLast Modified:
I have the following python script that needs to be converted to C#

I'm wondering if anyone has any code generators that will do this, and paste the output C#


import asyncio
import random

host = 'localhost'
port = 5027

messageLogin = bytearray.fromhex('000F313233343536373839303132333435')
messageLocation = bytearray.fromhex('000000000000002b080100000140d4e3ec6e000cc661d01674a5e0fffc00000900000004020100f0000242322318000000000100007a04')

devices = 100
period = 1

class AsyncClient(asyncio.Protocol):

    def __init__(self, loop):
        self.loop = loop
        self.buffer = memoryview(messageLogin)

    def connection_made(self, transport):

    def send_message(self, transport):
        self.buffer = memoryview(messageLocation)
        delay = period * (0.9 + 0.2 * random.random())
        self.loop.call_later(delay, self.send_message, transport)

    def data_received(self, data):

    def connection_lost(self, exc):

loop = asyncio.get_event_loop()

for i in range(0, devices):
    loop.create_task(loop.create_connection(lambda: AsyncClient(loop), host, port))

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros