Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SCL 1.06 KB | None | 0 0
  1. PROGRAM TCP_Server_program
  2. VAR
  3.     Server1: TCP_Server;
  4.     sDataSend: STRING(80);
  5.     xStart: BOOL;
  6.     aReceiveBuffer: ARRAY [0..MAX_RECEIVE_TCP_SERVER] OF BYTE;
  7.     diReceiveCount: DINT;
  8.     ptTekstOdb: POINTER TO STRING;
  9. END_VAR
  10.  
  11.  
  12. (* Wywolanie bloku funkcyjnego TCP_Server z biblioteki WAGOLIBETHERNET_01 *)
  13. Server1(
  14.     xEnable:= TRUE,
  15.     wPortNumber:= 1200,
  16.     tServerTimeOut:= T#20s,
  17.     ptSendData:= ADR(sDataSend),
  18.     diSendCount:= LEN(sDataSend),
  19.     xStartSend:= xStart,
  20.     aReceiveBuffer:= aReceiveBuffer,
  21.     diReceiveCount:= diReceiveCount,
  22.     xClientConnected=> ,
  23.     diError=> ,
  24.     dwIP_AddressOfClient=> );
  25.  
  26.  
  27. (* Program działa w ten sposób, że to co przyjdzie od Clienta TCP
  28. zostanie spowrotem odesłane *)
  29.  
  30. (* Wyjscia z bloku funkcyjnego TCP_SERVER *)
  31. xdo2 := Server1.xClientConnected;
  32. Server1.diError;
  33. Server1.dwIP_AddressOfClient;
  34. (*********************************************************)
  35.  
  36. ptTekstOdb := ADR(aReceiveBuffer);
  37.  
  38. IF diReceiveCount > 0 THEN
  39.     aReceiveBuffer[diReceiveCount] := 0;
  40.     diReceiveCount := 0;
  41.     sDataSend := ptTekstOdb^;
  42.     xStart := TRUE;
  43. END_IF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement