class Socket
class Socket
lib/net/socket/socket.tya:22
Socket represents a TCP stream connection.
Source
# Socket represents a TCP stream connection.
class Socket implements Readable, Writable, Closable
# Socket.binary stores instance state.
# @type Nil
binary: nil
# Socket.handle stores instance state.
# @type Nil
handle: nil
# Socket.initialize provides the net/socket/Socket standard library operation.
# @param handle Any handle value.
# @param binary Boolean binary value.
# @return Self the initialized object.
initialize: handle, binary ->
self.handle = handle
self.binary = binary
# Socket.close provides the net/socket/Socket standard library operation.
# @return Nil the resulting value.
close: ->
socket_close(self.handle)
# Socket.closed? provides the net/socket/Socket standard library operation.
# @return Boolean whether the condition is true.
closed?: ->
socket_closed(self.handle)
# connect opens a TCP connection to host and port.
# Raises when the connection cannot be established.
# @param host String host value.
# @param port Any port value.
# @param options Dict options value.
# @return Any the resulting value.
connect: host, port, options ->
if options == nil
options = {}
Socket(socket_connect(host, port, options), options["mode"] == "binary")
# Socket.local_address provides the net/socket/Socket standard library operation.
# @return Any the resulting value.
local_address: ->
socket_local_address(self.handle)
# read returns up to size bytes from the socket.
# Raises when the socket read fails.
# @param size Int size value.
# @return Any the resulting value.
read: size ->
socket_read(self.handle, size)
# Socket.read_line provides the net/socket/Socket standard library operation.
# @return String the resulting value.
read_line: ->
socket_read_line(self.handle)
# Socket.remote_address provides the net/socket/Socket standard library operation.
# @return Any the resulting value.
remote_address: ->
socket_remote_address(self.handle)
# write sends value to the socket and returns the byte count.
# Raises when the socket write fails.
# @param value String value value.
# @return Any the resulting value.
write: value ->
socket_write(self.handle, value)
# Socket.write_line provides the net/socket/Socket standard library operation.
# @param value String value value.
# @return Any the resulting value.
write_line: value ->
self.write(value)
self.write("\n")
Instance Variables
binary
Socket.binary
lib/net/socket/socket.tya:25
Socket.binary stores instance state.
Source
# Socket.binary stores instance state.
# @type Nil
binary: nil
handle
Socket.handle
lib/net/socket/socket.tya:29
Socket.handle stores instance state.
Source
# Socket.handle stores instance state.
# @type Nil
handle: nil
Methods
close
Socket.close()
lib/net/socket/socket.tya:41
Socket.close provides the net/socket/Socket standard library operation.
Source
# Socket.close provides the net/socket/Socket standard library operation.
# @return Nil the resulting value.
close: ->
socket_close(self.handle)
closed?
Socket.closed?()
lib/net/socket/socket.tya:46
Socket.closed? provides the net/socket/Socket standard library operation.
Source
# Socket.closed? provides the net/socket/Socket standard library operation.
# @return Boolean whether the condition is true.
closed?: ->
socket_closed(self.handle)
connect
Socket.connect(host, port, options)
lib/net/socket/socket.tya:55
connect opens a TCP connection to host and port. Raises when the connection cannot be established.
Source
# connect opens a TCP connection to host and port.
# Raises when the connection cannot be established.
# @param host String host value.
# @param port Any port value.
# @param options Dict options value.
# @return Any the resulting value.
connect: host, port, options ->
if options == nil
options = {}
Socket(socket_connect(host, port, options), options["mode"] == "binary")
initialize
Socket.initialize(handle, binary)
lib/net/socket/socket.tya:35
Socket.initialize provides the net/socket/Socket standard library operation.
Source
# Socket.initialize provides the net/socket/Socket standard library operation.
# @param handle Any handle value.
# @param binary Boolean binary value.
# @return Self the initialized object.
initialize: handle, binary ->
self.handle = handle
self.binary = binary
local_address
Socket.local_address()
lib/net/socket/socket.tya:62
Socket.local_address provides the net/socket/Socket standard library operation.
Source
# Socket.local_address provides the net/socket/Socket standard library operation.
# @return Any the resulting value.
local_address: ->
socket_local_address(self.handle)
read
Socket.read(size)
lib/net/socket/socket.tya:69
read returns up to size bytes from the socket. Raises when the socket read fails.
Source
# read returns up to size bytes from the socket.
# Raises when the socket read fails.
# @param size Int size value.
# @return Any the resulting value.
read: size ->
socket_read(self.handle, size)
read_line
Socket.read_line()
lib/net/socket/socket.tya:74
Socket.read_line provides the net/socket/Socket standard library operation.
Source
# Socket.read_line provides the net/socket/Socket standard library operation.
# @return String the resulting value.
read_line: ->
socket_read_line(self.handle)
remote_address
Socket.remote_address()
lib/net/socket/socket.tya:79
Socket.remote_address provides the net/socket/Socket standard library operation.
Source
# Socket.remote_address provides the net/socket/Socket standard library operation.
# @return Any the resulting value.
remote_address: ->
socket_remote_address(self.handle)
write
Socket.write(value)
lib/net/socket/socket.tya:86
write sends value to the socket and returns the byte count. Raises when the socket write fails.
Source
# write sends value to the socket and returns the byte count.
# Raises when the socket write fails.
# @param value String value value.
# @return Any the resulting value.
write: value ->
socket_write(self.handle, value)
write_line
Socket.write_line(value)
lib/net/socket/socket.tya:92
Socket.write_line provides the net/socket/Socket standard library operation.
Source
# Socket.write_line provides the net/socket/Socket standard library operation.
# @param value String value value.
# @return Any the resulting value.
write_line: value ->
self.write(value)
self.write("\n")