FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-osc/pythonosc/udp_client.py at master · sxing/python-osc · GitHub
sxing
/
python-osc
Public
forked from
attwad/python-osc
Notifications
You must be signed in to change notification settings
Fork
0
Star
3
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-osc
/
pythonosc
/
udp_client.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (21 loc) · 995 Bytes
Breadcrumbs
python-osc
/
pythonosc
/
udp_client.py
Copy path
File metadata and controls
28 lines (21 loc) · 995 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Client to send OSC datagrams to an OSC server via UDP."""
import
ipaddress
import
socket
class
UDPClient
(
object
):
"""OSC client to send OscMessages or OscBundles via UDP."""
def
__init__
(
self
,
address
,
port
,
ttl_hops
=
1
,
interface
=
None
):
"""Initialize the client.
As this is UDP it will not actually make any attempt to connect to the
given server at ip:port until the send() method is called.
"""
self
.
_sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
if
(
ipaddress
.
ip_address
(
address
).
is_multicast
):
self
.
_sock
.
setsockopt
(
socket
.
IPPROTO_IP
,
socket
.
IP_MULTICAST_TTL
,
ttl_hops
)
if
(
interface
!=
None
):
self
.
_sock
.
setsockopt
(
socket
.
IPPROTO_IP
,
socket
.
IP_MULTICAST_IF
,
socket
.
inet_aton
(
interface
))
self
.
_sock
.
setblocking
(
0
)
self
.
_address
=
address
self
.
_port
=
port
def
send
(
self
,
content
):
"""Sends an OscBundle or OscMessage to the server."""
self
.
_sock
.
sendto
(
content
.
dgram
, (
self
.
_address
,
self
.
_port
))
Back
|
FazBrowse Home
|
New Git URL