| Platform | Since |
|---|---|
| Android | 1.7 |
| iPhone | 1.7 |
| iPad | 1.7 |
TCP socket that implements the Titanium.IOStream interface. Created by Titanium.Network.Socket.createTCP
| Name | Summary |
|---|---|
| accept |
Tells a LISTENING socket to accept a connection request at the top of a listener's request queue when one becomes available. Takes an argument, a box object which assigns callbacks to the created socket. Note that the connected callback is not called (the socket does not "transition to" the CONNECTED state - it's created in the CONNECTED state) on the newly created socket. The accepted callback is called when a new connection is accepted as a result of calling accept(). If the socket is already flagged to accept the next connection, the existing accept options will be update to use the newly specified options object. Throws an exception if the socket is not in a LISTENING state |
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| close |
Closes a socket. Throws exception if the socket is not in a CONNECTED or LISTENING state. Blocking |
| connect |
Attempts to connect the socket to its host/port. Throws exception if the socket is in a CONNECTED or LISTENING state. Throws exception if a valid host and port has not been set on the proxy. Nonblocking; connection attempts are asynchronous |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| getAccepted |
Gets the value of the accepted property. |
| getConnected |
Gets the value of the connected property. |
| getError |
Gets the value of the error property. |
| getHost |
Gets the value of the host property. |
| getListenQueueSize |
Gets the value of the listenQueueSize property. |
| getPort |
Gets the value of the port property. |
| getState |
Gets the value of the state property. |
| getTimeout |
Gets the value of the timeout property. |
| listen |
Attempts to start listening on the socket's host/port. listen() call will attempt to listen on the specified host and/or port property for the socket if they are set. This function blocks execution and throws an exception on error (and sets the socket state to ERROR) but does not fire the error callback in this event. Throws exception if the socket is in a LISTENING or CONNECTED state |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| setAccepted |
Sets the value of the accepted property. |
| setConnected |
Sets the value of the connected property. |
| setError |
Sets the value of the error property. |
| setHost |
Sets the value of the host property. |
| setListenQueueSize |
Sets the value of the listenQueueSize property. |
| setPort |
Sets the value of the port property. |
| setTimeout |
Sets the value of the timeout property. |
| Name | Type | Summary |
|---|---|---|
| accepted | Callback<AcceptedCallbackArgs> |
The callback to be fired when a listener accepts a connection |
| connected | Callback<ConnectedCallbackArgs> |
The callback to be fired after the socket enters the "connected" state. Only invoked following a successful connect() call |
| error | Callback<ErrorCallbackArgs> |
The callback to be fired after the socket enters the ERROR state |
| host | String |
The host to connect to or listen on. Cannot be modified when not in the INITIALIZED state. Supports both IPv4 and IPv6 |
| listenQueueSize | Number |
Max number of pending incoming connections to be allowed when listen() is called. Any incoming connections received while the max number of pending connections has been reached will be rejected. |
| port | Number |
The port to connect to or listen on. Cannot be modified when not in the INITIALIZED state |
| state | Number |
current state of the socket read-only |
| timeout | Number |
The timeout for connect() and all I/O write() operations. Cannot be modified when not in the INITIALIZED state |