mergSocket is an iOS external that provides TCP and UDP (datagram) client and server sockets.
Documentation
Opening TCP Sockets
command mergSocketOpen pHostAndPort
Open a socket
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
Sets the result to an error message if there was one
message mergSocketConnected pHostAndPort
Sent to the control that called mergSocketOpen.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
command mergSocketAcceptConnections pPort,[pDatagram]
Accept connections on a port
Parameters:
- pPort - the port to accep connections on
- pDatagram - (optional with "false" default) set to true if you want to accept datagrams
- false
- true
Sets the result to an error message if there was one
message mergSocketNewConnection pHostAndPort
Sent to the control that called mergSocketAcceptConnections.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
Reading From TCP Sockets
command mergSocketRead pHostAndPort,[pLength],[pTimeout]
Read from the socket
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pLength - (optional with 0 default) Read for pLength bytes. If 0 is specified then read all available bytes.
- pTimeout - (optional with 10 default) A socket timeout
command mergSocketReadTo pHostAndPort,pData,[pTimeout]
Read from the socket until specifed data is found.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pData - Read up until and including the data
- pTimeout - (optional with 10 default) A socket timeout
message mergSocketDidReadData pHostAndPort,pData
Sent to the control that called mergSocketAcceptConnections or mergSocketOpen when the read is completed.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pData - The data read from the socket
message mergSocketDidReadPartialDataOfLength pHostAndPort,pLength
Sent to the control that called mergSocketAcceptConnections or mergSocketOpen at intervals during a long read.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pLength - The among of data read from the socket
Writing To TCP Sockets
command mergSocketWrite pHostAndPort,pData,[pTimeout]
Write data to the socket
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pData - The data to write to the socket
- pTimeout - (optional with 10 default) A socket timeout
message mergSocketDidWriteData pHostAndPort
Sent to the control that called mergSocketAcceptConnections or mergSocketOpen when the write is completed.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
message mergSocketDidWritePartialDataOfLength pHostAndPort,pLength
Sent to the control that called mergSocketAcceptConnections or mergSocketOpen at intervals during a long write.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pLength - The among of data written to the socket
Closing TCP Sockets
command mergSocketClose pHostAndPort
Close the socket
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
UDP Sockets (datagram)
command mergSocketSendDatagram pHostAndPort,pData,[pTimeout],[pBroadcast]
Send a datagram. This single command opens the socket and sends the datagram.
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pData - The data to send
- pTimeout - (optional with 10 default) A socket timeout
- pBroadcast - (optional with "false" default) Allow broadcasting
- false
- true
message mergSocketDatagramSent pHostAndPort
Sent to the control that called mergSocketSendDatagram
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
message mergSocketDatagramNotSent pHostAndPort,pError
Sent to the control that called mergSocketSendDatagram
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pError - An error string
message mergSocketDatagramRecieved pHostAndPort,pData
Sent to the control that called mergSocketAcceptConnections with the pDatagram parameter true
Parameters:
- pHostAndPort - An hostname:port string where hostname may be an IP or domain name
- pData - The data in the datagram
General
function mergSocketListOpen
List the currently open sockets
Returns returns a list of hostname:port or for accept connections just port