Skip to content

shadowmoses1997/ZmqServerClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repo introduction -> server client application with ZMQ

Hello :)

This lib contains two programs.

One is on the client side and the other is on the server side.

Well, let's do a short review on this lib.

The server side :

server.py in the first step runs a device.

more info for the device :

The device is the interface between the client and the socket nodes.

It listens the frontend and is connected to the backend (socket nodes)

device can listen to a specific address and After load balancing, it sends the request to one of the nodes.

device

I implemented this method ->

device

For more information you can read this Article

After receiving the Json request:

Checks the request

Executes the commands

Returns the answer as Jason

The server understand two types of commands: expression & system commands.

exp:
    '{"command_type": "os", "command_name": "echo", "parameters": "HelloWorld"}'
    '{"command_type": "compute", "expression": "(40 + 60) * 2"}'

The client side :

This program sends your requests to the server through a socket connection.

usage :

mode os : you can send system commands to the server.

mode compute : you can perform your mathematical calculations on the server side.

Finally, you can recive the Json response.

You can run the client side program in two ways.

1 -> you can create an instance of the Client class and send the input in the form of send_request method.

from client import Client

import json

dict_request = {'command_type': 'os', 'command_name': 'echo', 'parameters': 'HelloWorld'}

json_request = json.dumps(dict_request)

client = Client()

print(client.send_request(json_request))

2 -> You can also send arguments in the $hell->

    exp 1: python .\client.py --mode='os' --command='ping 127.0.0.1' --arg='-n 6'

    exp 2: python .\client.py --mode='compute' --expression='5*5'

Enter this command in the terminal to see how to do this $hell->

python client.py --help

For Test the server, you can enter the command in the $hell->

python server_unittest.py

Installion of libraries :

pip install -r requirements.txt

About

the Client Server program with ZMQ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages