-
Notifications
You must be signed in to change notification settings - Fork 16
/
deno_udp.deno.txt
63 lines (41 loc) · 3.48 KB
/
deno_udp.deno.txt
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
DENO_UDP
VERSION ==> #See deno doc
/=+===============================+=\
/ : : \
)==: OPEN :==(
\ :_______________________________: /
\=+===============================+=/
Deno.listenDatagran(UDP_OPTS)
->>DCONN !#Open UDP socket
UDP_OPTS #Inherits STCP_OPTS except:
# - no reusePort
# - transport 'tcp|unix' -> 'udp|unixpacket'
UDP_OPTS.reuseAddress #BOOL (def: false). If true and another process listens on same port, steals it.
/=+===============================+=\
/ : : \
)==: DATA :==(
\ :_______________________________: /
\=+===============================+=/
DCONN #ASYNC_ITERABLE of [UINT8ARR, ADDR] (data + sender)
#Inherits CLOSER
DCONN.addr #ADDR of source
DCONN.send(UINT8ARR, ADDR)->>NUM #Returns NUM bytes sent
DCONN.receive([UINT8ARR])
->>[UINT8ARR, ADDR] #Can pass UINT8ARR to reuse the same one, to avoid re-allocating memory
/=+===============================+=\
/ : : \
)==: MULTICAST :==(
\ :_______________________________: /
\=+===============================+=/
DCONN.joinMulticastv4
('HOST', 'NETWORK_INTERFACE')
->>MEMBERSHIP
DCONN.joinMulticastv6
('HOST', NETWORK_INTERFACE_NUM)
->>MEMBERSHIP #Join multicast group
MEMBERSHIP.leave()->> #Leave multicast group
UDP_OPTS.loopback
MEMBERSHIP.setLoopback(BOOL)->> #BOOL (def: false). Send multicast packets to localhost
MEMBERSHIP.setTTL(NUM)->> #Set multicast packets TTL. Only with IPv4