https://github.com/gaming32/network-script
Library for calling methods over sockets
https://github.com/gaming32/network-script
library network python
Last synced: 8 months ago
JSON representation
Library for calling methods over sockets
- Host: GitHub
- URL: https://github.com/gaming32/network-script
- Owner: Gaming32
- License: mit
- Created: 2020-01-27T23:24:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-08T20:23:31.000Z (over 6 years ago)
- Last Synced: 2025-07-10T16:37:02.449Z (12 months ago)
- Topics: library, network, python
- Language: Python
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Installing
To install use the command `python -m pip install Network-Script`.
# Basic Tutorial
## Server
To start off import the `Server` class:
``` python
from netsc import Server
```
Then create a subclass of the `Server` class, defining `bind_addr` and possibly `sock_family`, `sock_type`, and `sock_proto`:
``` python
class MyServer(Server):
bind_addr = ('', 1920)
```
Then create an instance, define the object it wraps, and accept a connection:
``` python
server = MyServer(wrapped_obj)
server.accept()
```
## Client
To start off import the `Client` class:
``` python
from netsc import Client
```
Then create a subclass of the `Client` class, possibly defining `sock_family`, `sock_type`, and `sock_proto`:
``` python
class MyClient(Client):
pass
```
Then create an instance, define the object it wraps, and connect to a server:
``` python
client = MyClient(wrapped_obj)
client.connect(('localhost', 1920))
```
## From then
From now on one end can call the `poll` method, and the other end can then call any method and get any attribute of the wrapped class. Note concerning attributes: to get an attribute the attribute must be listed in the `attrs` attribute of the end initiating the attribute get.