Networking help in Python

A forum for general discussion of the Python programming language.

Networking help in Python

Postby qwerty » Wed Jul 09, 2014 6:52 am

I'm pretty mush new to python and need to analyse this code, this code I think wants to send msg to some remote host and listen to its reply to make sure that there is connectivity. However I am not sure how this code is working. Please give me ideas how to understand this exactly, I'm reading several online tutorial on python as well, but since I have limited time, would need help from you all.

double undescore is for private, I know, rest plz give some hints. Thanks

Code: Select all
class sendMessage(asyncore.dispatcher_with_send):

    def __init__(self, host, text, port=12121):
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((host, port))

    def handle_read(self):
        print self.recv(1024)

    def handle_close(self):

request = sendMessage("",text)
Last edited by stranac on Wed Jul 09, 2014 9:52 am, edited 2 times in total.
Reason: First post lock. Fixed code tags.
Posts: 1
Joined: Wed Jul 09, 2014 3:57 am

Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, Yahoo [Bot] and 6 guests