PROGRAM PLC_PRG VAR strAddress : STRING := '127.0.0.1'; uiPort : UINT := 4711; bDone : BOOL; iState : INT := 0; iSend : INT := 0; iReceive : INT := 0; my_UDPSocketAsyncServer: IL_UDPSocketAsync; my_UDPSocketAsyncClient: IL_UDPSocketAsync; my_UDPRecvfromAsync: IL_UDPRecvfromAsync; my_UDPSendtoAsync: IL_UDPSendtoAsync; END_VAR CASE iState OF 0: my_UDPSocketAsyncServer.Enable := TRUE; my_UDPSocketAsyncClient.Enable := TRUE; IF my_UDPSocketAsyncServer.InOperation AND my_UDPSocketAsyncClient.InOperation THEN iState:= 10; END_IF 10: my_UDPRecvfromAsync.Execute := TRUE; iState:= 20; 20: my_UDPSendtoAsync.Execute := TRUE; IF my_UDPSendtoAsync.Done AND my_UDPRecvfromAsync.Done THEN iSend := iSend + 1; my_UDPSendtoAsync.Execute := FALSE; my_UDPRecvfromAsync.Execute := FALSE; iState:= 10; END_IF END_CASE my_UDPSocketAsyncServer( Enable:= , InOperation=> , Shutdown=> , Error=> , ErrorID=> , ErrorIdent=> , Server:= TRUE, Address:= , Port:= uiPort, Socket=> ); my_UDPSocketAsyncClient( Enable:= , InOperation=> , Shutdown=> , Error=> , ErrorID=> , ErrorIdent=> , Server:= , Address:= strAddress, Port:= uiPort, Socket=> ); my_UDPRecvfromAsync( Execute:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Socket:= my_UDPSocketAsyncServer.Socket, ValueAdr:= ADR(iReceive), NoOfBytes:= SIZEOF(iReceive), SocketAddr=> , NoOfRecBytes=> ); my_UDPSendtoAsync( Execute:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Socket:= my_UDPSocketAsyncClient.Socket, ValueAdr:= ADR(iSend), Address:= strAddress, Port:= uiPort, NoOfBytes:= SIZEOF(iSend), NoOfSendBytes=> );