在共享主机服务器发送事件(SSE)或长轮询上实现实时通知的最佳方法是什么?
我看了一个视频说SSE不适合共享主机,Apache服务器并不适合PHP和MySql.
我只是想知道哪种技术更适合长轮询或SSE在共享服务器上进行实时通知,我在godaddy.com上有我的服务器
请提供解释推荐技术的良好链接.
我正在尝试建立一个客户端 - 服务器模型,是python网络编程的新手,我遇到了一个错误,其中说明了以下内容: -
tcpCliSoc.send('[%s]%s'%(bytes(ctime(),'utf_8'),data))
TypeError:需要一个类似字节的对象,而不是'str'
这是服务器和客户端实现
TCP服务器实现
from socket import *
from time import ctime
HOST = ''
PORT = 21572
ADDR = (HOST, PORT)
BUFFSIZE = 1024
tcpSerSoc = socket(AF_INET, SOCK_STREAM)
tcpSerSoc.bind(ADDR)
tcpSerSoc.listen(5)
while True:
print("waiting for connection......")
tcpCliSoc, addr = tcpSerSoc.accept()
print("connected from", addr)
while True:
data = tcpCliSoc.recv(BUFFSIZE)
if not data:
break
tcpCliSoc.send('[%s] %s' % (bytes(ctime(), 'utf_8'), data))
tcpCliSoc.close()
tcpSerSoc.close()
Run Code Online (Sandbox Code Playgroud)
TCP客户端实现
from socket import *
__author__ = 'Lamer'
HOST = 'localhost'
PORT = 21572
ADDR = …Run Code Online (Sandbox Code Playgroud)