# ws2udp
A WebSocket to UDP proxy.
**ws2udp** will forward messages coming from the WebSocket server to UDP sockets, it is especially useful
to send OSC messages from JavaScript applications to SuperCollider or any other software that doesn't support
WebSockets. It registers all websockets connected and will broadcast messages sent to its own UDP port.
## Installation
You will need Python>=3.7 and the websockets package.
The simplest way to install is using pip:
`$ pip install ws2udp`
## Example
```
$ ws2udp
WebSocket to UDP proxy
optional arguments:
-h, --help show this help message and exit
--udp-addr UDP_ADDR Address of the UDP receiver for broadcasting messages (default=localhost)
--udp-port UDP_PORT Port of the UDP receiver (default=57142)
--fwd-fixed Forward UDP to fixed target address/port
--fwd-addr FWD_ADDR Address of the UDP target for messages (default=localhost)
--fwd-port FWD_PORT Port of the UDP target (default=57143)
--addr ADDR WebSocket address to listen (default=0.0.0.0)
--port PORT WebSocket port to listen (default=8765)
--broadcast Enable UDP broadcasting
--quiet No verbose output
```
If the `fwd-fixed` option is not given (default behavior),
the server expects binary messages following the format:
**address_length**(uint32)**address**(string)**port**(uint32)**data**
* _address_length_ is an integer representing the total length of the address
* _address_ the address where to forward the data as a string (example: localhost)
* _port_ as an integer
* _data_ the original message data
For example, to send the message `hello world` to `localhost:57120`, one would send:
`b'\x09\x00\x00\x00localhost\x20\xdf\x00\x00hello, world'`
The first 4 bytes `b'\x09\x00\x00\x00` represents 9, then comes `b'localhost'` and lastly `b'\x20\xdf\x00\x00'` for 57120. Whatever comes after this is forwarded.
If the `fwd-fixed` option is given, the original message data will be forwarded unaltered.
Raw data
{
"_id": null,
"home_page": "https://github.com/bgola/ws2udp",
"name": "ws2udp",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "websockets udp osc opensoundcontrol",
"author": "Bruno Gola, additions by Thomas Grill",
"author_email": "me@bgo.la, gr@grrrr.org",
"download_url": "https://files.pythonhosted.org/packages/14/48/38b25f3ee94e608e98a8467fd2af29e21a66fcced6f5c1589d954d5cd28f/ws2udp-0.1.7.tar.gz",
"platform": null,
"description": "# ws2udp\n\nA WebSocket to UDP proxy. \n\n**ws2udp** will forward messages coming from the WebSocket server to UDP sockets, it is especially useful\nto send OSC messages from JavaScript applications to SuperCollider or any other software that doesn't support\nWebSockets. It registers all websockets connected and will broadcast messages sent to its own UDP port.\n\n## Installation\n\nYou will need Python>=3.7 and the websockets package.\n\nThe simplest way to install is using pip:\n\n`$ pip install ws2udp`\n\n## Example\n\n```\n$ ws2udp\nWebSocket to UDP proxy\n\noptional arguments:\n -h, --help show this help message and exit\n --udp-addr UDP_ADDR Address of the UDP receiver for broadcasting messages (default=localhost)\n --udp-port UDP_PORT Port of the UDP receiver (default=57142)\n --fwd-fixed Forward UDP to fixed target address/port\n --fwd-addr FWD_ADDR Address of the UDP target for messages (default=localhost)\n --fwd-port FWD_PORT Port of the UDP target (default=57143)\n --addr ADDR WebSocket address to listen (default=0.0.0.0)\n --port PORT WebSocket port to listen (default=8765)\n --broadcast Enable UDP broadcasting\n --quiet No verbose output\n```\n\nIf the `fwd-fixed` option is not given (default behavior),\nthe server expects binary messages following the format:\n\n**address_length**(uint32)**address**(string)**port**(uint32)**data**\n\n* _address_length_ is an integer representing the total length of the address\n* _address_ the address where to forward the data as a string (example: localhost)\n* _port_ as an integer\n* _data_ the original message data\n\nFor example, to send the message `hello world` to `localhost:57120`, one would send:\n\n`b'\\x09\\x00\\x00\\x00localhost\\x20\\xdf\\x00\\x00hello, world'`\n\nThe first 4 bytes `b'\\x09\\x00\\x00\\x00` represents 9, then comes `b'localhost'` and lastly `b'\\x20\\xdf\\x00\\x00'` for 57120. Whatever comes after this is forwarded.\n\n\nIf the `fwd-fixed` option is given, the original message data will be forwarded unaltered.\n",
"bugtrack_url": null,
"license": null,
"summary": "A WebSocket to UDP proxy",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/bgola/ws2udp"
},
"split_keywords": [
"websockets",
"udp",
"osc",
"opensoundcontrol"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "86d2e3bcdfb25085e0d2353bd5ea8a051607069f06933f2bf9369b020cd66aaf",
"md5": "851b51bd6b50b9932c49089ea14edc45",
"sha256": "5c0447980885ca940374f5829f7cc21ae6c4ce1fe2a8c01ff5edeb70024b44a8"
},
"downloads": -1,
"filename": "ws2udp-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "851b51bd6b50b9932c49089ea14edc45",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 17938,
"upload_time": "2024-05-03T06:37:30",
"upload_time_iso_8601": "2024-05-03T06:37:30.410761Z",
"url": "https://files.pythonhosted.org/packages/86/d2/e3bcdfb25085e0d2353bd5ea8a051607069f06933f2bf9369b020cd66aaf/ws2udp-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "144838b25f3ee94e608e98a8467fd2af29e21a66fcced6f5c1589d954d5cd28f",
"md5": "3680d20acfffbb0ac198348046f851f0",
"sha256": "cddd1c59c7885727822a74dc3e002b6c48e07a1ebd92fd0b850c3eb426bfac89"
},
"downloads": -1,
"filename": "ws2udp-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "3680d20acfffbb0ac198348046f851f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 17252,
"upload_time": "2024-05-03T06:37:36",
"upload_time_iso_8601": "2024-05-03T06:37:36.077275Z",
"url": "https://files.pythonhosted.org/packages/14/48/38b25f3ee94e608e98a8467fd2af29e21a66fcced6f5c1589d954d5cd28f/ws2udp-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-03 06:37:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bgola",
"github_project": "ws2udp",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ws2udp"
}