Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM TCP_Server_program
- VAR
- Server1: TCP_Server;
- sDataSend: STRING(80);
- xStart: BOOL;
- aReceiveBuffer: ARRAY [0..MAX_RECEIVE_TCP_SERVER] OF BYTE;
- diReceiveCount: DINT;
- ptTekstOdb: POINTER TO STRING;
- END_VAR
- (* Wywolanie bloku funkcyjnego TCP_Server z biblioteki WAGOLIBETHERNET_01 *)
- Server1(
- xEnable:= TRUE,
- wPortNumber:= 1200,
- tServerTimeOut:= T#20s,
- ptSendData:= ADR(sDataSend),
- diSendCount:= LEN(sDataSend),
- xStartSend:= xStart,
- aReceiveBuffer:= aReceiveBuffer,
- diReceiveCount:= diReceiveCount,
- xClientConnected=> ,
- diError=> ,
- dwIP_AddressOfClient=> );
- (* Program działa w ten sposób, że to co przyjdzie od Clienta TCP
- zostanie spowrotem odesłane *)
- (* Wyjscia z bloku funkcyjnego TCP_SERVER *)
- xdo2 := Server1.xClientConnected;
- Server1.diError;
- Server1.dwIP_AddressOfClient;
- (*********************************************************)
- ptTekstOdb := ADR(aReceiveBuffer);
- IF diReceiveCount > 0 THEN
- aReceiveBuffer[diReceiveCount] := 0;
- diReceiveCount := 0;
- sDataSend := ptTekstOdb^;
- xStart := TRUE;
- END_IF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement