PROGRAM PLC_PRG VAR strAddress : STRING := '127.0.0.1'; uiPort : UINT := 4712; iState : INT := 0; iSend : INT := 0; iReceive : INT := 0; my_IL_TCPConnectionAsyncServer: IL_TCPConnectionAsync; my_IL_TCPConnectionAsyncClient: IL_TCPConnectionAsync; my_IL_TCPRecvAsync: IL_TCPRecvAsync; my_IL_TCPSendAsync: IL_TCPSendAsync; END_VAR CASE iState OF 0: my_IL_TCPConnectionAsyncServer.Enable := TRUE; IF my_IL_TCPConnectionAsyncServer.Active THEN iState:= 5; END_IF 5: my_IL_TCPConnectionAsyncClient.Enable := TRUE; IF my_IL_TCPConnectionAsyncClient.Active THEN iState:= 7; END_IF 7: IF my_IL_TCPConnectionAsyncClient.Done AND my_IL_TCPConnectionAsyncServer.Done THEN iState:= 10; END_IF 10: my_IL_TCPRecvAsync.Execute := TRUE; iState:= 20; 20: my_IL_TCPSendAsync.Execute := TRUE; IF my_IL_TCPSendAsync.Done AND my_IL_TCPRecvAsync.Done THEN iSend := iSend + 1; my_IL_TCPSendAsync.Execute := FALSE; my_IL_TCPRecvAsync.Execute := FALSE; iState:= 10; END_IF END_CASE my_IL_TCPConnectionAsyncServer( Enable:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Server:= TRUE, Address:= strAddress, Port:= uiPort, Socket=> ); my_IL_TCPConnectionAsyncClient( Enable:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Server:= , Address:= strAddress, Port:= uiPort, Socket=> ); my_IL_TCPRecvAsync( Execute:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Socket:= my_IL_TCPConnectionAsyncServer.Socket, ValueAdr:= ADR(iReceive), NoOfBytes:= SIZEOF(iReceive), NoOfRecBytes=> ); my_IL_TCPSendAsync( Execute:= , Done=> , Active=> , Error=> , ErrorID=> , ErrorIdent=> , Socket:= my_IL_TCPConnectionAsyncClient.Socket, ValueAdr:= ADR(iSend), NoOfBytes:= SIZEOF(iSend), NoOfSendBytes=> );