Socket
A TCP socket class : allow you to both connect to a given server and exchange messages or start your own server and wait for connections.
Instance Members
input: haxe.io.InputThe stream on which you can read available data. By default the stream is blocking until the requested data is available,
use setBlocking(false) or setTimeout to prevent infinite waiting.
output: haxe.io.OutputThe stream on which you can send data. Please note that in case the output buffer you will block while writing the data, use setBlocking(false) or setTimeout to prevent that.
close(): VoidCloses the socket : make sure to properly close all your sockets or you will crash when you run out of file descriptors.
Write the whole data to the socket output.
Note*: this is not meant to be used together with setBlocking(false), as
haxe.io.Error.Blocked may be thrown mid-write with no indication of how many bytes have been written.
output.writeBytes() should be used instead as it returns this information.
| Name | Type |
|---|---|
content |
String |
Connect to the given server host/port. Throw an exception in case we couldn't successfully connect.
| Name | Type |
|---|---|
host |
Host |
port |
Int |
Shutdown the socket, either for reading or writing.
| Name | Type |
|---|---|
read |
Bool |
write |
Bool |
Gives a timeout (in seconds) after which blocking socket operations (such as reading and writing) will abort and throw an exception.
| Name | Type |
|---|---|
timeout |
Float |
Change the blocking mode of the socket. A blocking socket is the default behavior. A non-blocking socket will abort blocking operations immediately by throwing a haxe.io.Error.Blocked value.
| Name | Type |
|---|---|
b |
Bool |
Allows the socket to immediately send the data when written to its output : this will cause less ping but might increase the number of packets / data size, especially when doing a lot of small writes.
| Name | Type |
|---|---|
b |
Bool |
new(): VoidCreates a new unconnected socket.
Private Members
init(): Void