Socket
Description
A simple %Socket interface.
API overview
Constructor
Socket
()
Functions
Public functions
| accept (): Socket |
native Creates a new Socket for a newly created connection |
| bind ( host: String , port: Number , backlog: Number = 32 ): Socket |
static native Creates a Socket instance bound to the specified host and port |
| clearError (): Void |
native Clears the last socket error |
| close (): Void |
native Disconnects from the host and closes the socket |
| connect ( host: String , port: Number ): Socket |
static native Creates a Socket instance connected to the specified host and port |
| getError ( clear: Boolean = true ): String |
native Retrieves an error (if any) that the socket returns |
| receive (): String |
native Receives a message from the accepted socket |
| send ( msg: String ): Void |
native Sends a message to the accepted socket |
| setTimeout ( milliseconds: Number ): Void |
native Sets a timeout (in ms) for the socket to connect/send/recieve messages |
Constructor
Socket ()
Functions
accept (): Socket
native
Creates a new Socket for a newly created connection.
Returns
| Socket | A Socket for a newly created connection. |
bind ( host: String , port: Number , backlog: Number = 32 ): Socket
static native
Creates a Socket instance bound to the specified host and port.
Parameters
| host: String | The host for the connection. |
| port: Number | The port for the connection. |
| backlog: Number = 32 |
Returns
| Socket | The Socket instance. |
connect ( host: String , port: Number ): Socket
static native
Creates a Socket instance connected to the specified host and port.
Parameters
| host: String | The host for the connection. |
| port: Number | The port for the connection. |
Returns
| Socket | The Socket instance. |
getError ( clear: Boolean = true ): String
native
Retrieves an error (if any) that the socket returns.
Parameters
| clear: Boolean = true | Specifies whether to clear the message upon reading. Defaults to true. |
Returns
| String | The error string. |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
receive (): String
native
Receives a message from the accepted socket.
Returns
| String | The recieved message string. |