NETLink::Send()

Description

Send() is used to send count items from a data array over the NETLink.

Call Signature

int Send ( any ptr data [, int count] )

Return Value

int

0 is returned on failure and a non-zero value for success.

Arguments

any ptr data:

Pointer to an array of data of type byte, char, int, float or double which should be sent over the link.

[ int count ]:

Number of items of the type of data to be sent. If not specified the count is derived from the size of the data array.

Remarks

If data is not of one of the indicated types an error will occur.

Example

Send an array of points over a network link. The count has to be placed into an int array in order to ensure that a ptr, rather than an integer, value gets passed into the Send() call. This isn't an issue with the xy_pts where the Send() derives the amount of data from the array itself.


 local NETLink ptr poLink 
 local double ptr xy_pts
 local int i
 local int j
 
 ! Allocate memory for a vector containing 2 vertices
 ! Note: each vertex has a pair of doubles 
 xy_pts = EAlloc(double,2*100)
 
 ! Create a 100 vertice vector
 for i=0 to 99
     j=i*2 
	 xy_pts[j+1]= i
	 xy_pts[j+2]= i
 endfor
 
 ! Open a link to an established port 
 poLink = NETLinkOpen("localhost",1306)
 
 ! Send it 100 times
 for i = 1 to 100
	call SendVector(xy_pts,poLink)
 endfor

! Destroy link
 call poLink.Destroy

 ! Free memory
 call EFree(xy_pts)

define function SendVector(xy_pts, poLink)
 local int ptr cnt

 ! Allocate memory for size holder
 cnt = EAlloc(int,1)

 ! Send count of vertices
 cnt[1] = f$len(xy_pts) / 2
 call poLink.Send( cnt )
 
 ! Send vector data
 if ( poLink.Send( xy_pts )  > 0 ) then

	 ! Get acknowledgement - original size sent
	 if (  poLink.Accept( cnt ) > 0 ) then
		 if ( cnt[1] != f$len(xy_pts) / 2) then
			print "Error: points accepted were " + cnt
		 else
			print "Success sending vector data at time = " + f$time
		 endif
	 else
	     print "Error: acknowledgement could not be received"
	 endif
 else
    print "Error: could not send data for vector"
 endif
 
 ! Free memory
 call EFree(cnt)
enddefine


See also

NETLink class

Inter-process communication

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.