Accepts an internet connection and creates a socket for that connection.
# Syntax
accept [datagram] connections on port portNumber with message callbackMessage
# Parameters - pObject : reference to an object - pType : a metadata type - pTag : the name of the metadata item to set - pValue : the new value to set the item to.
# Examples
accept connections on port 80 with message "connectionMade"
accept datagram connections on port 80 with message "connectionMade"
on mouseUp accept connections on port 80 with message "connectionMade" end mouseUp on connectionMade pIPAddress put "Connection made:" && pIPAddress end connectionMade
# Related
* __property:__ HTTPProxy, script * __command:__ read from socket, write to socket, close socket, open socket * __function:__ openSockets, hostAddressToName, hostName, hostAddress, peerAddress, hostNameToAddress * __glossary:__ datagram, IP address, TCP, port, command, socket, UDP, host, server, message, parameter, process * __object:__ object
# Description
Use the __accept__ command when running a server, to accept TCP connections or UDP datagrams from other systems (or other processes on the same system). Use the datagram option if you want to accept UDP datagrams.
When a connection is made or a datagram is received, the __accept__ command creates a new socket that can be used to communicate with the other system (or process). When using the close socket, read from socket, or write to socket commands, you can refer to this socket with a socket identifier that looks like this: host:port[|connectionID] where the connectionID is a number assigned by the __accept__ command. (You only need to specify the connection number if there is more than one socket connected to a particular port and host.)
The callbackMessage is sent to the object whose script contains the accept command. Either one or two parameters are sent with this message. The first parameter is the IP address of the system or process making the connection. If a datagram is being accepted, the second parameter is the contents of the datagram.
For technical information about sockets, see RFC 147 at http://www.ietf.org/rfc/rfc147.txt. For technical information about UDP datagrams, see RFC 768 at http://www.ietf.org/rfc/rfc0768.txt. For technical information about the numbers used to designate standard ports, see the list of port numbers at http://www.iana.org/assignments/port-numbers, in particular the section entitled "Well Known Port Numbers".
* Type: command * Introduced: 1.0 * OS: mac,windows,linux,ios,android * Platforms: desktop,server,web,mobile