Component: TCP Template (Comms: Networking)

From Flowcode Help
Jump to navigationJump to search
Author Matrix Ltd.
Version 2.2
Category Comms: Networking


TCP Template component

Base TCP/IP component with simulation only interface to allow TCP/IP style network communications in simulation. Suitable for inheriting

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TCPIP_Base.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TCPIP_Base.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Additional examples can be found in the “Apps and Bundles” section of this Wiki:

Internet Application Guide

Wireless LAN Application Guide






Macro reference

AcceptClose

Fc9-comp-macro.png AcceptClose
Close the accept socket 
Fc9-void-icon.png - VOID Return


AcceptOpen

Fc9-comp-macro.png AcceptOpen
 
Fc9-u8-icon.png - BYTE Return


Connect

Fc9-comp-macro.png Connect
Attempt to connect to the given address and port. First open a socket on the local device using the Socket function and check that it is successful.  
Fc9-string-icon.png - STRING Address
Remote destination address 
Fc9-u16-icon.png - UINT Port
Remote destination port 
Fc9-u8-icon.png - BYTE Return


CreateIPSocket

Fc9-comp-macro.png CreateIPSocket
Note that sockets on up to 4 channels can be simultaneously opened and these channels are numbered 0 to 3. Note that sockets with different modes can be opened on different channels. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Protocol
Specifies which IP protocol to use 
Fc9-u8-icon.png - BYTE Broadcast
Allows broadcast type packets to be sent and received 
Fc9-u8-icon.png - BYTE Return


CreateMACSocket

Fc9-comp-macro.png CreateMACSocket
This macro creates a socket for sending and receiving Ethernet data using raw data. 
Fc9-u8-icon.png - BYTE Promiscuous
Receive everything (1) or just data bound for your MAC (0) 
Fc9-u8-icon.png - BYTE Broadcast
Allows broadcast messages to be accepted (1) or rejected (0) 
Fc9-u8-icon.png - BYTE Error
Allowsmessages with errors to be accepted (1) or rejected (0) 
Fc9-u8-icon.png - BYTE Return


CreateTCPSocket

Fc9-comp-macro.png CreateTCPSocket
This macro creates a socket for sending and receiving TCP data. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Src_Port_Hi
Port High Byte 
Fc9-u8-icon.png - BYTE Src_Port_Lo
Port Low Byte 
Fc9-u8-icon.png - BYTE Return


CreateUDPSocket

Fc9-comp-macro.png CreateUDPSocket
This macro creates a socket for sending and receiving UDP data. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Src_Port_Hi
Port High Byte 
Fc9-u8-icon.png - BYTE Src_Port_Lo
Port Low Byte 
Fc9-u8-icon.png - BYTE Return


ForcePropEvent

Fc9-comp-macro.png ForcePropEvent
Allows the property event to be fired, doing things like fetching the correct IP for the network interface. 
Fc9-void-icon.png - VOID Return


GetConsole

Fc9-comp-macro.png GetConsole
Obtain the console instance for the TCP/IP base. 
Fc9-h32-icon.png - HANDLE Return


GetPropertyVal

Fc9-comp-macro.png GetPropertyVal
 
Fc9-string-icon.png - STRING Property
 
Fc9-string-icon.png - STRING Return


GetSocketStatus

Fc9-comp-macro.png GetSocketStatus
This returns the state of the requested channel's socket. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


Initialise

Fc9-comp-macro.png Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros  
Fc9-void-icon.png - VOID Return


Listen

Fc9-comp-macro.png Listen
Bind the socket to a port on the local host and set to listen mode. First open a socket on the local device using the Socket function and check that it is successful.  
Fc9-u16-icon.png - UINT Port
 
Fc9-u8-icon.png - BYTE Return


Receive

Fc9-comp-macro.png Receive
Receive data into the data buffer. Returns the number of bytes received 
Fc9-string-icon.png - STRING Data
Data byte buffer to receive the data 
Fc9-u16-icon.png - UINT Count
Maximum number of bytes to read 
Fc9-u16-icon.png - UINT Return


RxDataAvailable

Fc9-comp-macro.png RxDataAvailable
This macro is used to check whether or not data has been received by the Internet E-Block. A return value of zero indicated that no data has been received. A positive return value indicates that data is available. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxDataSize

Fc9-comp-macro.png RxDataSize
This macro is used to detect the size of data collected by the Rx_data_available macro. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxFlushData

Fc9-comp-macro.png RxFlushData
Once data reception has been completed, this macro should be called to discard the data packet and allow other data packets to be read. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


RxMatchMyIP

Fc9-comp-macro.png RxMatchMyIP
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's IP address. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxMatchMyMAC

Fc9-comp-macro.png RxMatchMyMAC
This macro returns a non-zero value when the next 6 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's MAC address entered in the component's property page. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxMatch_2_Bytes

Fc9-comp-macro.png RxMatch_2_Bytes
This macro returns a non-zero value when the next 2 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 4 bytes and 6 bytes. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Return


RxMatch_4_Bytes

Fc9-comp-macro.png RxMatch_4_Bytes
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 2 bytes and 6 bytes. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Byte3
Specifies the value of the third byte 
Fc9-u8-icon.png - BYTE Byte4
Specifies the value of the fourth byte 
Fc9-u8-icon.png - BYTE Return


RxMatch_6_Bytes

Fc9-comp-macro.png RxMatch_6_Bytes
This macro returns a non-zero value when the next 6 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 2 bytes and 4 bytes. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Byte3
Specifies the value of the third byte 
Fc9-u8-icon.png - BYTE Byte4
Specifies the value of the fourth byte 
Fc9-u8-icon.png - BYTE Byte5
Specifies the value of the fifth byte 
Fc9-u8-icon.png - BYTE Byte6
Specifies the value of the sixth byte 
Fc9-u8-icon.png - BYTE Return


RxReadByte

Fc9-comp-macro.png RxReadByte
A call to this macro will return a byte of data in the reception buffer of the specified channel. It will also internally increment a pointer to that data so that the next call to 'RxReadByte' (or any other read function) will read the next byte  
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Return


RxReadHeader

Fc9-comp-macro.png RxReadHeader
Once data in a particular channel has been received, the header will be filled with information about the received data. This macro will return the information in the header. The idx parameter specifies which byte of information in the header to read  
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Idx
Specifies the byte index to return 
Fc9-u8-icon.png - BYTE Return


RxReadString

Fc9-comp-macro.png RxReadString
A call to this macro will return a byte of data in the reception buffer of the specified channel. It will also internally increment a pointer to that data so that the next call to 'Rx_readbyte' (or any other read function) will read the next byte  
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Length
 
Fc9-string-icon.png - STRING Return


RxSkipBytes

Fc9-comp-macro.png RxSkipBytes
Often when receiving data packets, it may be necessary to ignore large sections of the data. This can be achieved by reading each byte individually (and ignoring the returned data), but a better way is to use this Rx_skipbytes macro. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Count
Specifies how many bytes to skip 
Fc9-void-icon.png - VOID Return


SecureClose

Fc9-comp-macro.png SecureClose
Close the secure connection 
Fc9-void-icon.png - VOID Return


SecureConnect

Fc9-comp-macro.png SecureConnect
Connect securely to host and port. e.g. “www.bbc.co.uk:443” Returns 1 if successful, 0 if not 
Fc9-string-icon.png - STRING host
Host:Port as string 
Fc9-s16-icon.png - INT Return


SecureInit

Fc9-comp-macro.png SecureInit
Call once to initialise the secure socket funtionality 
Fc9-void-icon.png - VOID Return


SecureRead

Fc9-comp-macro.png SecureRead
Attempts to read max number of bytes from the secure socket into the buffer. Returns actual number of bytes read. 
Fc9-string-icon.png - STRING buffer
 
Fc9-s16-icon.png - INT max
 
Fc9-s16-icon.png - INT Return


SecureWrite

Fc9-comp-macro.png SecureWrite
Attempts to write max number of bytes to the secure socket from the buffer. Returns actual number of bytes written. 
Fc9-string-icon.png - STRING buffer
 
Fc9-s16-icon.png - INT max
 
Fc9-s16-icon.png - INT Return


Send

Fc9-comp-macro.png Send
Send data 
Fc9-string-icon.png - STRING Data
Data byte buffer to send 
Fc9-u16-icon.png - UINT Count
Number of bytes to send 
Fc9-u16-icon.png - UINT Return


SendTo

Fc9-comp-macro.png SendTo
Send data to a destination host. Returns the number of bytes sent. 
Fc9-string-icon.png - STRING Data
Data byte buffer to send 
Fc9-u16-icon.png - UINT Count
Number of bytes to send 
Fc9-string-icon.png - STRING Address
 
Fc9-u16-icon.png - UINT Port
 
Fc9-u16-icon.png - UINT Return


SetChannel

Fc9-comp-macro.png SetChannel
Dictates the TCP IP channel used for socket communications allowing for multiple parrallel communication streams to co-exist, Used by the network comms component to drive the TCP IP runtime comms 
Fc9-u8-icon.png - BYTE Channel
Range: 0 to 3 
Fc9-void-icon.png - VOID Return


SetDestination

Fc9-comp-macro.png SetDestination
This is used in IP and UDP modes to set the destination of the intended data transfer. The destination IP address needs to be set for both IP and UDP modes. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Dst_IP0
Specifies the first byte of an IP address 
Fc9-u8-icon.png - BYTE Dst_IP1
Specifies the second byte of an IP address 
Fc9-u8-icon.png - BYTE Dst_IP2
Specifies the third byte of an IP address 
Fc9-u8-icon.png - BYTE Dst_IP3
Specifies the fourth byte of an IP address 
Fc9-u8-icon.png - BYTE Dst_Port_Hi
Port High Byte 
Fc9-u8-icon.png - BYTE Dst_Port_Lo
Port Low Byte 
Fc9-void-icon.png - VOID Return


SetMyIP

Fc9-comp-macro.png SetMyIP
This macro sets up the Internet E-Block's own IP address. In most circumstances, this macro will not be required as the IP address setting in the component property page will remain constant throughout your application. 
Fc9-u8-icon.png - BYTE IP0
First Byte of IP address 
Fc9-u8-icon.png - BYTE IP1
Second Byte of IP address 
Fc9-u8-icon.png - BYTE IP2
Third Byte of IP address 
Fc9-u8-icon.png - BYTE IP3
Fourth Byte of IP address 
Fc9-void-icon.png - VOID Return


SetPropertyVal

Fc9-comp-macro.png SetPropertyVal
 
Fc9-string-icon.png - STRING Property
 
Fc9-string-icon.png - STRING Value
 
Fc9-void-icon.png - VOID Return


SocketClose

Fc9-comp-macro.png SocketClose
Close the socket 
Fc9-void-icon.png - VOID Return


SocketOpen

Fc9-comp-macro.png SocketOpen
Attempts to create a socket on the local device. Type =0 for TCP, =1 for UDP This must be successfully done before attempting connection with a remote destination. Returns 1 if successful, 0 if not. 
Fc9-u8-icon.png - BYTE Type
Type of socket to create 
Fc9-u8-icon.png - BYTE Return


TCPClose

Fc9-comp-macro.png TCPClose
When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TCPConnect

Fc9-comp-macro.png TCPConnect
This macro puts a previously opened TCP channel in "active open" mode. This is the required mode when writing a TCP client application (e.g. using SMTP to send an email). 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Dst_IP0
First Byte of IP address 
Fc9-u8-icon.png - BYTE Dst_IP1
Second Byte of IP address 
Fc9-u8-icon.png - BYTE Dst_IP2
Third Byte of IP address 
Fc9-u8-icon.png - BYTE Dst_IP3
Fourth Byte of IP address 
Fc9-u8-icon.png - BYTE Dst_Port_Hi
High Byte of destination port 
Fc9-u8-icon.png - BYTE Dst_Port_Lo
Low Byte of destination port 
Fc9-u8-icon.png - BYTE Return


TCPListen

Fc9-comp-macro.png TCPListen
This macro puts a previously opened TCP channel in "passive open" mode. This is the required mode when writing a TCP server application (e.g. a web server to display HTML web pages). 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxEnd

Fc9-comp-macro.png TxEnd
Once the transmit buffer has been filled with data, call this macro to actually send the data. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxSendByte

Fc9-comp-macro.png TxSendByte
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a single byte of data, or with a string of information. 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


TxSendMyIP

Fc9-comp-macro.png TxSendMyIP
This macro fills the specified channel's transmit buffer with 4 bytes of data representing this Internet E-Block's IP address as specified in the component's property page. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxSendMyMAC

Fc9-comp-macro.png TxSendMyMAC
This macro fills the specified channel's transmit buffer with 6 bytes of data representing this Internet E-Block's MAC address as specified in the component's property page. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxSendString

Fc9-comp-macro.png TxSendString
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a single byte of data, or with a string of information. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-string-icon.png - STRING Data
Data byte to append to Tx buffer. 
Fc9-void-icon.png - VOID Return


TxStart

Fc9-comp-macro.png TxStart
This macro indicates the start of data transmission for the specified buffer. In TCP mode, data transmission can only begin once the socket has become established. In other modes, data transmission can occur as soon as the socket has been opened. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-10-icon.png Hostname
Local PC's hostname 
Fc9-type-16-icon.png Network Interface
List of network interfaces connected to the PC. Sets which interface we are communicating via. 
Fc9-conn-icon.png Gateway IP
Fc9-type-14-icon.png Gateway0
Gateway IP address to the Internet, auto populated from the selected interface. 
Fc9-type-14-icon.png Gateway1
Gateway IP address to the Internet, auto populated from the selected interface. 
Fc9-type-14-icon.png Gateway2
Gateway IP address to the Internet, auto populated from the selected interface. 
Fc9-type-14-icon.png Gateway3
Gateway IP address to the Internet, auto populated from the selected interface. 
Fc9-conn-icon.png Subnet Mask
Fc9-type-14-icon.png Subnet0
Network IP subnet mask, auto populated from the selected interface. 
Fc9-type-14-icon.png Subnet1
Network IP subnet mask, auto populated from the selected interface. 
Fc9-type-14-icon.png Subnet2
Network IP subnet mask, auto populated from the selected interface. 
Fc9-type-14-icon.png Subnet3
Network IP subnet mask, auto populated from the selected interface. 
Fc9-conn-icon.png IP Address
Fc9-type-14-icon.png IP0
Network IP address, auto populated from the selected interface. 
Fc9-type-14-icon.png IP1
Network IP address, auto populated from the selected interface. 
Fc9-type-14-icon.png IP2
Network IP address, auto populated from the selected interface. 
Fc9-type-14-icon.png IP3
Network IP address, auto populated from the selected interface. 
Fc9-conn-icon.png MAC Address
Fc9-type-14-icon.png MAC0
Network MAC address, auto populated from the selected interface. 
Fc9-type-14-icon.png MAC1
Network MAC address, auto populated from the selected interface. 
Fc9-type-14-icon.png MAC2
Network MAC address, auto populated from the selected interface. 
Fc9-type-14-icon.png MAC3
Network MAC address, auto populated from the selected interface. 
Fc9-type-14-icon.png MAC4
Network MAC address, auto populated from the selected interface. 
Fc9-type-14-icon.png MAC5
Network MAC address, auto populated from the selected interface. 
Fc9-conn-icon.png Notify
Fc9-type-7-icon.png Console Data
Generate Console Data 
Fc9-type-17-icon.png Target
Sets a target object, to which User.Notify events will be sent when data is sent and received. Events are send with Message ID = this component's handle, Data: 1=Send, 2=Receive.