File: bd_client.py

package info (click to toggle)
pexpect 2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 584 kB
  • ctags: 701
  • sloc: python: 3,036; makefile: 46
file content (31 lines) | stat: -rwxr-xr-x 708 bytes parent folder | download
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
#!/usr/bin/env python
import socket
import sys, time, select

def recv_wrapper(s):
    r,w,e = select.select([s.fileno()],[],[], 2)
    if not r:
        return ''
    cols = int(s.recv(4))
    rows = int(s.recv(4))
    packet_size = cols * rows 
    return s.recv(packet_size)

HOST = '' #'localhost'    # The remote host
PORT = 1664 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
time.sleep(1)
#s.setblocking(0)
s.send('COMMAND' + '\x01' + sys.argv[1])
print recv_wrapper(s)
s.close()
sys.exit()
#while True:
#    data = recv_wrapper(s)
#    if data == '':
#        break
#    sys.stdout.write (data)
#    sys.stdout.flush()
#s.close()