do not bind 127_0_0_1 in socket server

本文介绍了一种服务器配置方法,该方法仅允许来自127.0.0.1的客户端连接,其他所有尝试连接的客户端将被拒绝。这对于提高服务器安全性、防止未经授权的外部访问非常有用。



otherwise the server can not accept any client connection other than 127.0.0.1

PROC SocketServer() VAR socketdev server_socket1; VAR socketdev client_socket1; VAR string client_ip:="192.168.225.169"; VAR string receive_string; VAR string string_j1:=""; VAR string string_j2:=""; VAR string string_j3:=""; VAR string string_j4:=""; VAR string string_j5:=""; VAR string string_j6:=""; VAR num num_j1:=0; VAR num num_j2:=0; VAR num num_j3:=0; VAR num num_j4:=0; VAR num num_j5:=0; VAR num num_j6:=0; VAR bool change_ok:=false; VAR robtarget current_position_robT; VAR jointtarget current_position_jointT; SocketClose server_socket1; SocketClose client_socket1; SocketCreate server_socket1; SocketBind server_socket1,"127.0.0.1",3000; SocketListen server_socket1; SocketAccept server_socket1,client_socket1\ClientAddress:=client_ip\Time:=WAIT_MAX; WHILE TRUE DO SocketReceive client_socket1\str:=receive_string\Time:=WAIT_MAX; ! TPWrite "receive_string="+receive_string; ! SocketSend client_socket1\Str:="Hello World"; string_j1:=StrPart(receive_string,1,6); string_j2:=StrPart(receive_string,7,6); string_j3:=StrPart(receive_string,13,6); string_j4:=StrPart(receive_string,19,6); string_j5:=StrPart(receive_string,25,6); string_j6:=StrPart(receive_string,31,6); change_ok:=StrToVal(string_j1,num_j1);!j1 change_ok:=StrToVal(string_j2,num_j2);!j2 change_ok:=StrToVal(string_j3,num_j3);!j3 change_ok:=StrToVal(string_j4,num_j4);!j4 change_ok:=StrToVal(string_j5,num_j5);!j5 change_ok:=StrToVal(string_j6,num_j6);!j6 current_position_robT:= CRobT(\Tool:=tool1\wobj:=wobj1); current_position_jointT:=CalcJointT(current_position_robT,tool1 \WObj:=wobj1); current_position_jointT:=Absjoffs(current_position_jointT,num_j1,num_j2,num_j3,num_j4,num_j5,num_j6); MoveAbsJ current_position_jointT\NoEOffs, v1000, fine, tool1; ENDWHILE ENDPROC FUNC jointtarget Absjoffs(jointtarget Point,num j10ffset,num j20ffset,num J30ffset,num J40ffset,num J50ffset,num J60ffset) VAR jointtarget joint_temp; joint_temp:=Point; joint_temp.robax.rax_1:=joint_temp.robax.rax_1+J10ffset; joint_temp.robax.rax_2:=joint_temp.robax.rax_2+J20ffset; joint_temp.robax.rax_3:=joint_temp.robax.rax_3+J30ffset; joint_temp.robax.rax_4:=joint_temp.robax.rax_4+J40ffset; joint_temp.robax.rax_5:=joint_temp.robax.rax_5+J50ffset; joint_temp.robax.rax_6:=joint_temp.robax.rax_6+J60ffset; RETURN joint_temp; ENDFUNC ENDMODULE这个代码为什么运行一下就立刻停止了
最新发布
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值