aboutsummaryrefslogtreecommitdiff
path: root/examples/socket-show-filename.tcl
blob: 03460966360be479a1a7c27c106e5ba9594ce804 (plain)
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
#!/usr/bin/env jimsh

# Shows what [$handle filename] returns for each socket type

foreach {type addr} {
	dgram {}
	dgram.server 5000
	dgram 127.0.0.1:5000
	pair {}
	pipe {}
	pty {}
	stream.server 127.0.0.1:5002
	stream 127.0.0.1:5002
	unix.server /tmp/uds.socket
	unix /tmp/uds.socket
	unix.dgram.server /tmp/uds.dgram.socket
	unix.dgram /tmp/uds.dgram.socket
} {
	try {
		set socks [socket $type {*}$addr]
		foreach s $socks {
			puts "$type $addr => [$s filename]"
		}
	} on error msg {
		puts "$type $addr => $msg"
	}
}