Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP Support -- maybe don't do #14

Open
sabjorn opened this issue Sep 25, 2023 · 0 comments
Open

UDP Support -- maybe don't do #14

sabjorn opened this issue Sep 25, 2023 · 0 comments

Comments

@sabjorn
Copy link
Owner

sabjorn commented Sep 25, 2023

with the regular Python socket, sending and receiving is a little different, from https://wiki.python.org/moin/UdpCommunication):

for UDP send

import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE = b"Hello, World!"

print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)

sock = socket.socket(socket.AF_INET, # Internet
        socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))```

UDP receive:

import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 5005

sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s" % data)


`recvfrom` and `sendto` need to be overwritten. But also, the size of the buffer does matter. Basically, if a user needs to send a buffer over UDP it becomes their responsibility manage how many bytes to receive and possibly reconstruct on their end... which is not ideal.

UDP might even be pointless since slicing up an `np.ndarray` into smaller chunks and sending out of order or with dropped packets will result in it being impossible to reconstruct... 
 
successfully completing this includes creating new examples
@sabjorn sabjorn changed the title UDP Example UDP Support -- maybe don't do Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant