1
2
3 import socket, threading
4 import nuke
5 from nukescripts import utils
6
7 HOST='localhost'
8 PORT=50007
9
10
12 """
13 Example of running an IPV6 socket client to create nodes in Nuke.
14
15 from nukescripts import clientserver
16 c = clientserver.client()
17 c.send("Blur")
18 """
19
21 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
22 af, socktype, proto, canonname, sa = res
23 try:
24 self.s = socket.socket(af, socktype, proto)
25 except socket.error, msg:
26 self.s = None
27 continue
28 try:
29 self.s.connect(sa)
30 except socket.error, msg:
31 self.s.close()
32 self.s = None
33 continue
34 break
35
36 if not self.s: raise RuntimeError, "Unable to initialise client."
37
38 - def send(self, msg):
40
43
44
46 """
47 Example of running an IPV6 socket server on a separate thread inside Nuke.
48 The default command is to create the named node.
49
50 from nukescripts import clientserver
51 clientserver.threaded_server()
52 """
53
55 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
56 af, socktype, proto, canonname, sa = res
57 try:
58 self.s = socket.socket(af, socktype, proto)
59 except socket.error, msg:
60 self.s = None
61 continue
62 try:
63 self.s.bind(sa)
64 self.s.listen(1)
65 except socket.error, msg:
66 self.s.close()
67 self.s = None
68 continue
69 break
70
71 if not self.s: raise RuntimeError, "Unable to initialise server."
72
82
86
90