This is a simple wrapper for the socket library. It boils down to send and receive rather than worrying about setup and byte counts
To import this module, make sure the networking package is in the current directory. Run the following either in a Python interpreter or in a Python program
>>> from networking.Server import Server # Import the server module (on the server)
>>> from networking.Client import Client # Import the client module (on the client)
Create both objects, likely on different computers Creating the server object on the server (ip, port):
>>> port = 4444 # Change this to desired port
>>> s = Server("127.0.0.1", port) # Open port 4444 on local loopback
Creating the client object (ip, port):
>>> ip = "192.168.1.12" # Change this to desired ip
>>> port = 4444 # Change this to desired port
>>> c = Client(ip, port)
On the server open the port first:
>>> s.bind()
NOTE: This will hang until a connection is made from a client
On the client, connect to the port:
>>> c.connect()
The TCP connection is now completed
From either client or server: Use .send(str) to send information and .receive() to receive it
For example: On the server
>>> s.send("This is a test")
On the client
>>> c.receive()
'This is a test'
NOTE: .receive() will hang until data is received
If you would like to contribute, you may make a pull request. It will be helpful if you first open an issue describing the change that you are interested in contributing.