Diff of / linux-integr-prj,linux-integr,code/Device/Plc Logic/Application/PLC_PRG/svnobj [000000] .. [r2]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/ linux-integr-prj,linux-integr,code/Device/Plc Logic/Application/PLC_PRG/svnobj
@@ -0,0 +1,6 @@
+Gx_l;<!0…jüo\/–ò¸·gbP±System.StringL{6f9dac99-8de1-4efc-8465-68ac443b7d08}SpecialFuncL{0db3d7bb-cde0-4416-9a7b-ce49a0124323}NoneImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocument	L{f3878285-8e4f-490b-bb1b-9acbb7eb04db}
+TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}Id
longTagTextbIF hMySocket = RTS_INVALID_HANDLE  AND xOpen THENT	// create a socket for an IPv4 TCP streamš	hMySocket := SysSockCreate(	iAddressFamily	:= SOCKET_AF_INET, (* SOCKET_AF_INET for ip4 connection. We do it locally, so it is a loopback *)F								diType 			:= SOCKET_STREAM,V								diProtocol 		:= SOCKET_IPPROTO_TCP,D								pResult 		:= ADR(result));&	xIsBound := FALSE; 	xOpen := FALSE;END_IF	 Z// go through the process of binding the portrIF hMySocket <> RTS_INVALID_HANDLE AND NOT xIsBound THEN		†	// set up port to reuse address so we can bind to ANY ip (0.0.0.0)h	result := SysSockSetOption(	hSocket 		:= hMySocket,`								diLevel 		:= SOCKET_SOL, // socket level Ô								diOption 		:= SOCKET_SO_REUSEADDR, // allow using an addres (e.g. localhost or ANY) multiple times!l								pdiOptionValue 	:= ADR(diReuseAddr), // enable"Z								diOptionLen 	:= SIZEOF(diReuseAddr));#		$%	// fill out the struct used to pass along the binding information						&ˆ	socketAddress.sin_family := SOCKET_AF_INET; // same as on creation 'Ì	socketAddress.sin_addr.ulAddr := SOCKET_INADDR_ANY; // any means we bind it to all network interfaces(Ø	socketAddress.sin_port := SysSockHtons(1200); // the port number we chose, converted to ethernet byte order):	// now do the actual binding*`	result := SysSockBind(		hSocket 		:= hMySocket,+T								pSockAddr 		:= ADR(socketAddress),,d								diSockAddrSize 	:= SIZEOF(socketAddress));-								.J	xIsBound := result = Errors.ERR_OK;	/t	// set socket to start listening for incoming connections0b	result := SysSockListen(	hSocket 		:= hMySocket,1<								diMaxConnections:= 1);2d	xIsBound := xIsBound AND result = Errors.ERR_OK;	3à	// set the option for non-blocking so accept() returns immediatly instead of waiting until a connection is made4(	diNonblocking := 1;5b	result := SysSockIoctl(		hSocket			:= hMySocket,6x								diCommand		:= SOCKET_FIONBIO, // non-blocking option7v								pdiParameter	:= ADR(diNonblocking)); // set it to 18z xIsBound := xIsBound AND result = Errors.ERR_OK;												9END_IF::// accept incoming connection;’IF hMySocket <> RTS_INVALID_HANDLE AND xIsBound AND NOT xIsConnected THEN<Ú	// accept the connection if possible. As an output we get information about the socket we are connectiong to=v	hAcceptedSocket := SysSockAccept( 	hSocket 		:= hMySocket,>d										pSockAddr 		:= ADR(saConnectionPartner),?x										pdiSockAddrSize := ADR(diSaConnectionPartnerSize),@H										pResult 		:= ADR(result));A&																			Bn	xIsConnected := hAcceptedSocket <> RTS_INVALID_HANDLE;Cn	result := SysSockIoctl(		hSocket			:= hAcceptedSocket,Dž// use the handle of the accepted connection to read the data that is arriving.E|IF hAcceptedSocket <> RTS_INVALID_HANDLE AND xIsConnected THENFh	// build the data structure needed to read a socketG2	socketSet.fd_count := 1;HT	socketSet.fd_array[0] := hAcceptedSocket;IR	// check if there is anyhting to be readJÔ	result := SysSockSelect(	pfdRead := ADR(socketSet), // pointer to set of the sockets we want to select onK>					pfdWrite := 0, // not usedL@					pfdExcept := 0, // not usedM˜					diWidth := SOCKET_FD_SETSIZE, // maximum number of sockets in socketSetNP					ptvTimeout := ADR(tvSelectTimeout),O^					pdiReady := ADR(diSocketsReadyToReceive));PH	IF diSocketsReadyToReceive > 0 THENQT		// read the bytes waiting in the socket.RÊ		xiBytesReceived := SysSockRecv(		hSocket 		:= hAcceptedSocket, // the connected socket to read fromSz											pbyBuffer 		:= ADR(uiMessage), // where we read toT„											diBufferSize 	:= SIZEOF(uiMessage), // how much we readUh											diFlags 		:= SOCKET_MSG_NONE, // no flagsVL											pResult 		:= ADR(result)); W	END_IFX
+					YÚ	// if we don't have a timeout or we would not block, something failed, so connection must have dropped						ZÔ	IF result <> Errors.ERR_OK AND result <> Errors.ERR_TIMEOUT AND result <> Errors.ERR_SOCK_WOULDBLOCK THEN[0		xIsConnected := FALSE;\V		SysSockClose(hSocket := hAcceptedSocket);]P		hAcceptedSocket := RTS_INVALID_HANDLE;^(// close the socket._dIF hMySocket <> RTS_INVALID_HANDLE AND xClose THEN`H	SysSockClose(hSocket := hMySocket);aT	SysSockClose(hSocket := hAcceptedSocket);b$	xClose := FALSE; c.	xIsConnected := FALSE;dB	hMySocket := RTS_INVALID_HANDLE;eN	hAcceptedSocket := RTS_INVALID_HANDLE;f			gInterfacehL{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}iPROGRAM PLC_PRGjVARk2	result : RTS_IEC_RESULT;lª	hMySocket : RTS_IEC_HANDLE := RTS_INVALID_HANDLE; // handle for our receiving socketmÈ	hAcceptedSocket : RTS_IEC_HANDLE := RTS_INVALID_HANDLE; // handle for the connection to our partnern†	socketAddress : SOCKADDRESS; // temporary used as input for bind()o¸	saConnectionPartner : SOCKADDRESS; // socket address struct size of whoever connected to uspô	diSaConnectionPartnerSize : DINT := SIZEOF(saConnectionPartner); // socket address struct size of whoever connected to usq˜	socketSet : SOCKET_FD_SET; // temporary variable used as input for select()r`	xClose : BOOL; // initiating closing the socketsZ	xOpen : BOOL; // initiate opening the sockett|	xIsBound : BOOL; // indicates if the socket is open and boundu	xIsConnected : BOOL; // inidcates if someone is connected to the socketvl	uiMessage : UINT; // place to store incoming messageswt	xiBytesReceived : __XINT; // how many bytes were receivedxš	diReuseAddr	: DINT := 1; // always 1. It is passed into the set option call.y”	diNonblocking	: DINT := 1; // always 1. It is passed into the Ioctl call.zÜ	tvSelectTimeout: SOCKET_TIMEVAL; // Timeout of select(). Left all 0 which means none, i.e. return immediatly.{Ú	diSocketsReadyToReceive : DINT; // output for select() ontaining the number of ports that can be received on|END_VAR}"UniqueIdGenerator~191POULevel€L{8e575c5b-1d37-49c6-941b-5c0ec7874787}Standard‚ ChildObjectGuidsƒ8System.Collections.ArrayList„,AddAttributeSubsequent…boolÐÐ-ÐÐ	E
+lÐÐ
­AÚÐ-ÐÐ
­›ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­FÚÐ-ÐÐ
­vÚÐ-ÐÐ
­
+ÚÐ-ÐÐ
­œÚÐ-ÐÐ
­DÚÐ-ÐÐ
­?ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­ÚÐ-ÐÐ
­‘ÚÐ-ÐÐ
­’ÚÐ- ÐÐ
­•ÚÐ-!ÐÐ
­–ÚÐ-"ÐÐ
­“ÚÐ-#ÐÐ
­ŽÚÐ-$ÐÐ
­QÚÐ-%ÐÐ
­IÚÐ-&ÐÐ
­uÚÐ-'ÐÐ
­™ÚÐ-(ÐÐ
­KÚÐ-ÐÐ
­RÚÐ-)ÐÐ
­LÚÐ-*ÐÐ
­MÚÐ-+ÐÐ
­@ÚÐ-,ÐÐ
­…ÚÐ--ÐÐ
­†ÚÐ-.ÐÐ
­wÚÐ--ÐÐ
­yÚÐ-/ÐÐ
­zÚÐ-0ÐÐ
­xÚÐ-1ÐÐ
­SÚÐ-2ÐÐ
­‡ÚÐ-ÐÐ
­{ÚÐ-3ÐÐ
­„ÚÐ-4ÐÐ
­ÚÐ-5ÐÐ
­€ÚÐ-6ÐÐ
­ÚÐ-7ÐÐ
­|ÚÐ-8ÐÐ
­=ÚÐ-9ÐÐ
­ÚÐ-$ÐÐ
­CÚÐ-:ÐÐ
­ÚÐ-;ÐÐ
­YÚÐ-$ÐÐ
­bÚÐ-<ÐÐ
­\ÚÐ-=ÐÐ
­]ÚÐ->ÐÐ
­^ÚÐ-?ÐÐ
­_ÚÐ-@ÐÐ
­²ÚÐ-AÐÐ
­cÚÐ-BÐÐ
­´ÚÐ-ÐÐ
­¶ÚÐ-3ÐÐ
­·ÚÐ-4ÐÐ
­¸ÚÐ-CÐÐ
­¹ÚÐ-6ÐÐ
­µÚÐ-7ÐÐ
­WÚÐ-9ÐÐ
­!ÚÐ-$ÐÐ
­+ÚÐ-DÐÐ
­,ÚÐ-EÐÐ
­ŸÚÐ-FÐÐ
­kÚÐ-GÐÐ
­lÚÐ-HÐÐ
­£ÚÐ-$ÐÐ
­žÚÐ-IÐÐ
­ºÚÐ-JÐÐ
­»ÚÐ-KÐÐ
­¼ÚÐ-LÐÐ
­½ÚÐ-MÐÐ
­¾ÚÐ-NÐÐ
­¨ÚÐ-OÐÐ
­¤ÚÐ-ÐÐ
­©ÚÐ-PÐÐ
­mÚÐ-QÐÐ
­nÚÐ-RÐÐ
­oÚÐ-SÐÐ
­pÚÐ-TÐÐ
­qÚÐ-UÐÐ
­dÚÐ-VÐÐ
­°ÚÐ-WÐÐ
­ˆÚÐ-XÐÐ
­ ÚÐ-YÐÐ
­‰ÚÐ-ZÐÐ
­ŠÚÐ-[ÐÐ
­¿ÚÐ-\ÐÐ
­ŒÚÐ-]ÐÐ
­‹ÚÐ-WÐÐ
­eÚÐ-9ÐÐ
­4ÚÐ-$ÐÐ
­7ÚÐ-ÐÐ
­¢ÚÐ-^ÐÐ
­8ÚÐ-_ÐÐ
­9ÚÐ-`ÐÐ
­±ÚÐ-aÐÐ
­fÚÐ-bÐÐ
­gÚÐ-ÐÐ
­hÚÐ-cÐÐ
­iÚÐ-dÐÐ
­jÚÐ-eÐÐ
­:ÚÐ-9ÐÐ
­0ÚÐ-fÐÐ
­/ÚÐ-fÐghÐ	E
+ÐÐ
­ÚÐ-iÐÐ
­ÚÐ-jÐÐ
­ÚÐ-kÐÐ
­	ÚÐ-lÐÐ
­'ÚÐ-mÐÐ
­ÚÐ-nÐÐ
­#ÚÐ-oÐÐ
­%ÚÐ-pÐÐ
­*ÚÐ-qÐÐ
­5ÚÐ-ÐÐ
­6ÚÐ-rÐÐ
­BÚÐ-sÐÐ
­EÚÐ-tÐÐ
­UÚÐ-uÐÐ
­rÚÐ-ÐÐ
­sÚÐ-vÐÐ
­tÚÐ-wÐÐ
­‚ÚÐ-ÐÐ
­”ÚÐ-xÐÐ
­ƒÚÐ-yÐÐ
­ªÚÐ-ÐÐ
­¬ÚÐ-ÐÐ
­¯ÚÐ-zÐÐ
­«ÚÐ-{ÐÐ
­ÚÐ-|Ð}-~Ѐ-‚ƒЄ…­
\ No newline at end of file