# Inter-Process Communications (IPC)
![GitHub](https://img.shields.io/github/license/MomsFriendlyRobotCompany/ipc)
[![Latest Version](https://img.shields.io/pypi/v/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy/)
[![image](https://img.shields.io/pypi/pyversions/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy)
[![image](https://img.shields.io/pypi/format/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy)
![PyPI - Downloads](https://img.shields.io/pypi/dm/ipcpy?color=aqua)
A simple library to allow processes to use UDP to communicate
with each other.
This is yet again another rehash of old work in a new way ... I keep
reinventing the wheel. :)
**in development**
## Example
``` python
import ipcpy as ipc
import struct
from collections import namedtuple
MSG_SIZE = 4
TIMEOUT = 0.1
run = True
def client():
global run
print("Client started")
s = ipc.SocketUDP()
s.open(TIMEOUT)
for i in range(10):
pkt = struct.pack("<i", i)
print(f"send: {pkt}")
s.sendto(pkt, (HOST,PORT))
time.sleep(0.25)
run = False
def server():
global run
print("Client started")
s = ipc.SocketUDP()
s.bind(HOST,PORT,TIMEOUT)
while run:
data, address = s.recvfrom(MSG_SIZE)
if data is None:
continue
msg = struct.unpack("<i", data)
print(f"recvfrom: {address} {data} {msg}")
if __name__ =="__main__":
print(f"*** Main start ***")
t1 = threading.Thread(target=server)
t2 = threading.Thread(target=client)
t1.start()
t2.start()
t1.join()
t2.join()
print("*** Main stop ***")
```
# MIT License
**Copyright (c) 2003 Kevin J. Walchko**
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/ipcpy/",
"name": "ipcpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "udp, ipc, interprocess communication",
"author": "walchko",
"author_email": "walchko@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/e9/73/b0d151db317754a210948e97a953d435797be8fd884349c3ae07007dd1c2/ipcpy-2024.11.26.1.tar.gz",
"platform": null,
"description": "# Inter-Process Communications (IPC)\n![GitHub](https://img.shields.io/github/license/MomsFriendlyRobotCompany/ipc)\n[![Latest Version](https://img.shields.io/pypi/v/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy/)\n[![image](https://img.shields.io/pypi/pyversions/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy)\n[![image](https://img.shields.io/pypi/format/ipcpy.svg)](https://pypi.python.org/pypi/ipcpy)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/ipcpy?color=aqua)\n\n\nA simple library to allow processes to use UDP to communicate\nwith each other.\n\nThis is yet again another rehash of old work in a new way ... I keep\nreinventing the wheel. :)\n\n**in development**\n\n## Example\n\n``` python\nimport ipcpy as ipc\nimport struct\nfrom collections import namedtuple\n\nMSG_SIZE = 4\nTIMEOUT = 0.1\nrun = True\n\ndef client():\n global run\n print(\"Client started\")\n s = ipc.SocketUDP()\n s.open(TIMEOUT)\n\n for i in range(10):\n pkt = struct.pack(\"<i\", i)\n print(f\"send: {pkt}\")\n s.sendto(pkt, (HOST,PORT))\n time.sleep(0.25)\n\n run = False\n\ndef server():\n global run\n print(\"Client started\")\n s = ipc.SocketUDP()\n s.bind(HOST,PORT,TIMEOUT)\n\n while run:\n data, address = s.recvfrom(MSG_SIZE)\n\n if data is None:\n continue\n \n msg = struct.unpack(\"<i\", data)\n print(f\"recvfrom: {address} {data} {msg}\")\n \n\nif __name__ ==\"__main__\":\n print(f\"*** Main start ***\")\n t1 = threading.Thread(target=server)\n t2 = threading.Thread(target=client)\n\n t1.start()\n t2.start()\n\n t1.join()\n t2.join()\n print(\"*** Main stop ***\")\n```\n\n# MIT License\n\n**Copyright (c) 2003 Kevin J. Walchko**\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A interprocess communications (IPC) framework using UDP",
"version": "2024.11.26.1",
"project_urls": {
"Homepage": "https://pypi.org/project/ipcpy/",
"Repository": "https://github.com/MomsFriendlyRobotCompany/ipc/python"
},
"split_keywords": [
"udp",
" ipc",
" interprocess communication"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "72af48bd14d0401533fe2ab2d374a5b3567c182f9853af7117ea8a358d2c29ae",
"md5": "943ad5ae40f0c7555ca9a87ab633cbbe",
"sha256": "2e8a986e559afcd25a9d550ce801bbdf3573f4b2e9b5227337f5a43d44ac4649"
},
"downloads": -1,
"filename": "ipcpy-2024.11.26.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "943ad5ae40f0c7555ca9a87ab633cbbe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6365,
"upload_time": "2024-11-26T19:11:58",
"upload_time_iso_8601": "2024-11-26T19:11:58.157213Z",
"url": "https://files.pythonhosted.org/packages/72/af/48bd14d0401533fe2ab2d374a5b3567c182f9853af7117ea8a358d2c29ae/ipcpy-2024.11.26.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e973b0d151db317754a210948e97a953d435797be8fd884349c3ae07007dd1c2",
"md5": "ee17fa66abf9aa63c18a41994f8dae4d",
"sha256": "3660b2f1567b5ba457bcc23281682f8a9cd0a85fa255c7dd048d755274b6e980"
},
"downloads": -1,
"filename": "ipcpy-2024.11.26.1.tar.gz",
"has_sig": false,
"md5_digest": "ee17fa66abf9aa63c18a41994f8dae4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 5300,
"upload_time": "2024-11-26T19:11:59",
"upload_time_iso_8601": "2024-11-26T19:11:59.662192Z",
"url": "https://files.pythonhosted.org/packages/e9/73/b0d151db317754a210948e97a953d435797be8fd884349c3ae07007dd1c2/ipcpy-2024.11.26.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 19:11:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MomsFriendlyRobotCompany",
"github_project": "ipc",
"github_not_found": true,
"lcname": "ipcpy"
}