This article applies to:
E-Prime 3.0
E-Prime 2.0
E-Prime 1.x
This item was introduced in E-Prime 1.x (1.2.1.763).
Detail
NOTE: If using E-Prime 2.0 and beyond, you should use the GUI as this article does not apply. See the links at the end of this article. This feature breaks syntax compatibility with E-Prime 1.0/1.1. Using this item on a 1.0/1.1 runtime system will result in a compiler error. You are encouraged to use #if version tags to deter these errors.
This feature introduces the ability for E-Prime to open a client IP socket and communicate with listening server applications over a network connection.
The SocketDevice has the exact same properties and methods and behaviors where applicable as the SerialDevice.
In E-Prime 1.2, there is no GUI item to add in the Experiment Object > Devices area. User and InLine script must be used to open and use the SocketDevice. The following indicates a method to create and invoke a SocketDevice
USER SCRIPT
Dim MySocket As SocketDevice
INLINE TO OPEN
Set MySocket = New SocketDevice
MySocket.Name = "MySocket"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SocketDeviceInfo members
' .Server - The IP address or DNS name of the server attempting to be connected
' .Port - The port number that the server is listening
' .SocketType - ebSocketTypeTcp for TCP/IP connections. ebSocketTypeUdp not supported currently.
' .ByteOrdering - ebByteOrderingLittleEndian. ebByteOrderingBigEndian not currently supported.
' For ByteOrdering, strings are sent byte by byte ASCII. Byte ordering only applies
' for integers. For understanding of byte ordering google "Little Endian" or "Big Endian"
' See http://www.noveltheory.com/TechPapers/endian.asp
' Or http://www.cs.umass.edu/~verts/cs32/endian.html
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim theSocketDeviceInfo As SocketDeviceInfo
' can also be a DNS name of x.x.x.x IP address
theSocketDeviceInfo.Server = "192.168.100.1"
theSocketDeviceInfo.Port = 5000
theSocketDeviceInfo.SocketType = ebSocketTypeTcp
theSocketDeviceInfo.ByteOrdering = ebByteOrderingLittleEndian
'Open
MySocket.Open theSocketDeviceInfo
INLINE TO USE
Dim strData As String
Dim nRead As Long
nRead = MySocket.ReadString(strData)
'See ReadString, WriteString, ReadBytes, WriteBytes, InputCount, etc in SerialDevice and then replace Serial for Socket when using.
INLINE TO CLOSE
MySocket.FlushInputBuffer
MySocket.FlushOutputBuffer
Sleep 500
MySocket.Close
Set MySocket = Nothing
The variable to define/Dim the SocketDevice should be declared in User script area. The SocketDevice.Close must be called when you are finished with the SocketDevice communications (e.g. end of experiment) to avoid errors.
See Also:
DEVICE: How To: Socket Device Communication [25288]
DEVICE: Add a Socket object or device to support TCP/IP communications [16877]
Comments
0 comments
Please sign in to leave a comment.