Return to Snippet

Revision: 66288
at April 12, 2014 01:30 by JordanRowles


Updated Code
# 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

Revision: 66287
at April 12, 2014 01:19 by JordanRowles


Initial Code
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

Initial URL
SocketServer-Server

Initial Description
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

Initial Title
SocketServer_Server.py

Initial Tags
data, server

Initial Language
Python