#coding:utf-8
import threading
import os, os.path, sys
import win32process, win32event
import socket
handle = 0
hProcess=0
hThread=0
dwProcessId=0
dwThreadId =0
mpath = "c:\\Release"
mexe = "cefclient.exe"
def runexe(a):
try :
hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess(os.path.join(mpath, mexe),
'', None, None, 0,
win32process.CREATE_NO_WINDOW,
None ,
mpath,
win32process.STARTUPINFO())
#win32api.CloseHandle(hThread)
except Exception, e:
print "Create Error!"
handle = None
th1 = threading.Thread(target=runexe, args=(1,))
th1.setDaemon(True)
th1.start()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 49677))
sock.listen(5)
while True:
connection,address = sock.accept()
try:
connection.settimeout(5)
buf = connection.recv(1024)
uro = ("%s" % buf)
print uro
if (uro.find(":") > -1):
print "a"
#command = 'taskkill /f /im cefclient.exe'
#os.system(command)
except socket.timeout:
print 'time out'
connection.close()
python 套接字简单服务器端
最新推荐文章于 2022-05-23 23:31:44 发布