supersocket achieve your command

Now, if you have a command line protocol server instance "IronPythonServer", and we use Python to create a "ADD" command is used to make add two integers, then the results returned to the client, we have to complete the following A step of:

 

1. Create a python script file "ADD.py", and write the following:

 

def execute(session, request):

    session.Send(str(int(request[0]) + int(request[1])))

 

2. Place this file in a subdirectory of the working directory "Command" in

 

3.WorkRoot -> Command -> ADD.py

 

4. Start the server and client authentication through Telnet

telnet 127.0.0.1 2012

Client: ADD 100 150

Server: 250

 

You will find ADD.py located in the root folder of the Command, therefore SuperSocket allow all instances to load it. If you just want a server instance "IronPythonServer" to use it, you should put the script files into subdirectories "IronPythonServer" Command directory inside:

WorkRoot -> Command -> IronPythonServer -> ADD.py

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11127007.html