interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / host / tests / sockopt.om

58 lines · 1009 bytes Raw Blame History
1note Verify socket option effect with an independent bind outcome on an ephemeral loopback UDP port.
2global addr uchar 16
3text enabled "abcd"
4fn setreuse fd int option view uchar 8 to long
5ret add long 9 sockopt fd 1 2 option 2 4
6end
7fn main to int
8option = new uchar 8 0
9put option 2 1
10put addr 0 2
11put addr 4 127
12put addr 7 1
13a = socknew 2 2 0
14if lt a 0
15ret 1
16end
17b = socknew 2 2 0
18if lt b 0
19ret 2
20end
21if ne setreuse int a option 9
22ret 3
23end
24if ne bind int a addr 0 len addr 0
25ret 4
26end
27if ne sockname int a addr 0 len addr 16
28ret 5
29end
30if and eq get addr 2 0 eq get addr 3 0
31ret 6
32end
33if ne bind int b addr 0 len addr neg long 98
34ret 7
35end
36if ne sockopt int b 1 2 enabled 0 len enabled 0
37ret 8
38end
39if ne bind int b addr 0 len addr 0
40ret 9
41end
42if ne sockopt neg int 1 1 2 enabled 0 4 neg long 9
43ret 10
44end
45if ne sockopt int b 1 2 enabled 0 0 neg long 22
46ret 11
47end
48if ne sockopt int b 1 2147483647 enabled 0 4 neg long 92
49ret 12
50end
51if ne fclose int a 0
52ret 13
53end
54if ne fclose int b 0
55ret 14
56end
57ret 0
58end