| Platform | Since |
|---|---|
| iPhone | 1.2.0 |
| iPad | 1.2.0 |
| Mobile Web | 1.8 |
DEPRECATED: USE Titanium.Network.Socket.TCP WHERE POSSIBLE. The TCPSocket instance returned from Titanium.Network.createTCPSocket. This object represents a socket which either listens locally on the device for connections, or connects to a remote machine.
Sockets are nontrivial; it is recommended that anyone using them be familiar with the basics of BSD sockets. All sockets use TCP connections, and are asynchronous for read operations, so your program should be ready to receive 'read' events at any point. Socket references cannot be transferred to socket objects, and vice-versa - socket references are an internal mechanism which is used only to determine which sockets to send data to and read data from. For listening sockets, it is highly recommended that you use the Titanium.Network.INADDR_ANY constant as the host name. If a window containing a socket is closed, the socket MUST be closed also unless you intend to continue to receive data, otherwise the socket will consume resources (and potentially cause conflicts with opening the window again, if a listener) until the program is restarted. Be aware of the differences between the listen() and connect() functions; attempting to use one when you mean the other may result in errors, unpredictable behavior, or both.
| Name | Summary |
|---|---|
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| close |
Deprecated close the socket |
| connect |
Deprecated connect the scocket to a TCP server |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| getHostName |
Gets the value of the hostName property. |
| getIsValid |
Gets the value of the isValid property. |
| getMode |
Gets the value of the mode property. |
| getPort |
Gets the value of the port property. |
| getStripTerminator |
Gets the value of the stripTerminator property. |
| listen |
Deprecated set up the socket to receive connections |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| setHostName |
Sets the value of the hostName property. |
| setIsValid |
Sets the value of the isValid property. |
| setMode |
Sets the value of the mode property. |
| setPort |
Sets the value of the port property. |
| setStripTerminator |
Sets the value of the stripTerminator property. |
| write |
Deprecated write data to the socket, if the mode is WRITE_MODE or READ_WRITE_MODE |
| Name | Type | Summary |
|---|---|---|
| hostName | String |
Deprecated the host name to connect to. Must be |
| isValid | Boolean |
Deprecated whether or not the socket is valid |
| mode | Number |
Deprecated the socket's mode |
| port | Number |
Deprecated the port to connect/listen on |
| stripTerminator | Boolean |
Deprecated strip terminating null character when sending string data; default is false |
| Name | Summary |
|---|---|
| read |
Deprecated new data was read off the socket |
| readError |
Deprecated an error occured when reading |
| writeError |
Deprecated an error occured when writing |