New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

ipcpy

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipcpy

A interprocess communications (IPC) framework using UDP

2024.11.26.1
Maintainers
1

Inter-Process Communications (IPC)

GitHub Latest Version image image PyPI - Downloads

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

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts