4 connect% function – Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 113

Advertising
background image

8Ć3

function. This can be specified as a simple

variable or as an element of an array.

port%

is the local port number you want to give to the

socket. Begin assigning TCP and UDP port

numbers at 5000.
For raw Ethernet sockets, this value is used to

select the value of the 16Ćbit packet type in the

message header.

This function assigns a local port number or Ethernet packet type to

a socket.
Values Returned:
ă1

Success

-2

ENI not initialized

-4

Did not bind socket

-9

No buffer space

-15 Bad socket number
For example:

STATUS% = BIND%( SN%, 5000 )

8.4

CONNECT% Function

Format:

CONNECT%( sn%, addr$, port% )

where:

sn%

is the number of the socket you want to connect to

a destination. This is the value returned from the

SOCKET% function. This can be specified as a

simple variable or as an element of an array.

addr$

is the destination Internet or Ethernet address you

want to connect to. See ENI_INIT for applicable

rules for Internet addresses. Ethernet addresses

are 12Ćdigit Hex number strings.

port%

is the destination port number you want to connect

to.

This function assigns a permanent destination for a socket. It must

be done before any messages can be sent using any of the three

protocols. For Raw Ethernet or UDP sockets, this function is used

only to specify the destination address. For TCP sockets, it directs

the ENI to do an active open. A passive open (ACCEPT%), done by

the destination TCP socket, must occur prior to this function being

executed to establish a connection. After the connection is made,

messages can be exchanged.
If connecting a TCP socket and the other end is not ready to accept

the connection, the socket will be closed. To try to connect again,

the application must create a new socket and bind it again.
For raw Ethernet sockets, the port number defines the packet type

of all messages that will be sent. The receiving end must do a

BIND% with the same value for the port number.

Advertising
This manual is related to the following products: