PROC Server()
!声明变量
VAR socketdev temp_socket;
VAR socketdev client_socket;
VAR string received_string;
!清屏
TPErase;
!关闭之前的连接
SocketClose temp_socket;
SocketClose client_socket;
!创建新的连接
SocketCreate temp_socket;
!与新的指定服务器IP地址和端口号绑定
SocketBind temp_socket,"192.168.1.100",8005;
!用于开始监听输入连接,即开始充当服务器。
SocketListen temp_socket;
!用于接受输入连接请求。
SocketAccept temp_socket,client_socket;
!执行死循环,即一直处于收发状态
WHILE TRUE DO
SocketReceive client_socket\Str:=received_string; !等待接收数据
TPWrite "Client wrote - "+received_string; !写屏
SocketSend client_socket\Str:="Server Mes"; !接收以后发送反馈数据
ENDWHILE
!关闭连接
SocketClose temp_socket;
SocketClose client_socket;
ENDPROC
原文地址:https://www.cnblogs.com/yangshunwang/p/8371233.html