Advertisement
pantteri

Simple slave for distributed calculating

Sep 9th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # This module is an API for botnet bots.
  5. # See scheduler.py for botmaster.
  6. #
  7. # Code by Felix
  8.  
  9. import socket
  10.  
  11. class Slave:
  12.  
  13.     def __init__(self, host, myport=0):
  14.         self.host = host
  15.         self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  16.         self.myport = myport
  17.         s.bind(('', myport))
  18.  
  19.     # Returns unique id given by botmaster if successfull
  20.     # Returns -1 if unsuccessfull
  21.     def get_id(self):
  22.         try:
  23.             s.sendto('I am your slave.', self.host) # secret code
  24.             data, addr = s.recvfrom(1024)
  25.             if data.isdigit():
  26.                 return int(data)
  27.             else:
  28.                 return -1
  29.         except:
  30.             return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement