예제 #1
0
    def tcp(self, state):
        if state == 'on':
            self.recordButton.disable()
            self.TCPServer = tcp.TCP()
            self.TCPServer.listen(config.getTCPInfo()[0], int(config.getTCPInfo()[1]), timeout=0.01)

        elif state == 'off':
            self.recordButton.enable()
            self.TCPServer.close()
예제 #2
0
from config import getTCPInfo

import socket
import time

BUFFERSIZE = 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpInfo = getTCPInfo()
s.connect((tcpInfo[0], int(tcpInfo[1])))
s.setblocking(0)
try:
    while True:
        inputVar = str(raw_input("Enter msg: "))
        s.send(inputVar)
        try:
            print s.recv(BUFFERSIZE)
        except:
            pass

        if inputVar == 'quit':
            break

except KeyboardInterrupt:
    s.send('quit')
    pass

s.close()