File: qa-local-domain

package info (click to toggle)
newlisp 10.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 6,248 kB
  • sloc: ansic: 33,280; lisp: 4,181; sh: 609; makefile: 215
file content (50 lines) | stat: -rwxr-xr-x 1,057 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env newlisp

; test local domain UNIX sockets
; v 1.1 change net-receive for 10.0

(println)
(println "Testing UNIX local domain sockets")

(when (find ostype '("Windows" "OS/2"))
  (println "not tested on " ostype)
  (exit))

(define (listener path)
	(set 'lsock (net-listen path))
	(set 'csock (net-accept lsock))
	(net-receive csock buff 1024)
	(net-send csock (upper-case buff))
	(net-close csock)
	(exit)
)

(set 'pid (fork (listener "/tmp/mysock")))
(println "pid:" pid)

(while (not (set 'conn (net-connect "/tmp/mysock")))
	(sleep 100))

(if (not conn)
	(begin
		(println "Could not connect")
		(exit)))

(println "net-peer: " (net-peer conn))
(println "net-local: " (net-local conn))
(net-send conn "hello world")

(while (not (net-select conn "read" 1000))
	(println "waiting with net-select ..."))

(println "net-peek: " (net-peek conn))

(net-receive conn buff 1024)
(if (= "HELLO WORLD" buff)
	(println ">>>>> UNIX local domain sockets SUCCESSFUL")
	(prrintn ">>>>> PROBLEM with UNIX loxal domain sockets"))

(wait-pid pid)

(exit)