/ Published in: Python
A server that receives information from programs (Name, DateTime, LogType, Data) and writes it to a file with the syntax:
LogFile_{program_name}_{ISO-Date}.log
LogFile_{program_name}_{ISO-Date}.log
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# SocketServer_Server.py # Version: 1.0 # Use: Internal Application (Work) # Purpose: To log information to files from programs running on machines within the # network; but are not directly connected to each other. # Copyright (C)2014 Jordan Rowles # GNU General Public License Version 3 or Later import SocketServer class myTCPHandler(SocketServer.BaseRequestHandler): def handle(self): # self.request is the TCP socket connected to the client self.data = self.request.recv(1024).strip() print "{} Wrote:".format(self.client_address[0]) print self.data self.request.sendall(self.data.upper()) if __name__ == '__main__': HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST, PORT), myTCPHandler) server.serve_forever() # Interruptable with Ctrl-C
URL: SocketServer-Server