4 """make tcp socket connection with Oculus Prime Server Application 5 provide functions for relay of commands and messages""" 7 import socket, re, time
21 """Send single line command to server 23 s -- command to be sent 28 sock.sendall(s+
"\r\n")
37 """Read all incoming messages from server, do not return until search match 39 pattern -- regular expression pattern to be searched 40 returns first line containing match, or empty string if server shutdown 47 servermsg = (sockfileIO.readline()).strip()
49 if re.search(
"<telnet> shutdown", servermsg, re.IGNORECASE):
58 if re.search(pattern, servermsg, re.IGNORECASE):
67 """Clear socket buffer of all incoming server messages""" 69 sock.setblocking(
False)
76 sock.setblocking(
True)
80 """Search through unread output from server, compare to pattern, return match 81 stops reading buffer if finds a match 83 pattern -- regular expression pattern to be searched 84 returns: first line containing match, or empty string if search fails 90 sock.setblocking(
False)
93 servermsg = (sockfileIO.readline()).strip()
94 if re.search(pattern, servermsg, re.IGNORECASE):
99 sock.setblocking(
True)
104 """Make socket connection to server, blocking 106 returns: True if success, False otherwise 108 global sockfileIO, connected, sock
110 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
114 sock.connect((host, port))
122 sockfileIO = sock.makefile()
def waitForReplySearch(pattern)
def replyBufferSearch(pattern)