我不确定从哪里开始,到目前为止,我已经将它用于服务器端:
public static void main (String[] args) throws java.lang.Exception
{
String ad ="1<2";
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
Object result = engine.eval(ad);
System.out.println(Boolean.TRUE.equals(result)); // true
}
这对于客户端来说:
# Server program
from socket import *
import time
import sys
serverhost = '127.0.0.1'
serverport = 5005
buffersize = 2048
serversock = socket(AF_INET,SOCK_DGRAM)
serveraddr = (serverhost, serverport)
serversock.bind(serveraddr)
print 'Server is ready to receive'
while True:
try:
message, clientaddr = serversock.recvfrom(buffersize)
print 'Server received ', message, 'from ', str(clientaddr)
print "Server sending back " + str(message)
serversock.sendto(message, clientaddr)
except:
print 'Exception occured, closing socket'
break
serversock.close()
到目前为止,我不确定TCP标头是否正确,但如何开始消息交换?它应该是通过UDP发送具有TCP功能的数据包。我该如何开始连接(三次握手)?