# Creates a socket connection to host `host` on port `port`
init connect(host: String, port: Int)
do
# Creates a socket connection to host `host` on port `port`
init connect(host: String, port: Int)
do
_buffer_pos = 0
native = new NativeSocket.socket(new NativeSocketAddressFamilies.af_inet,
new NativeSocketTypes.sock_stream, new NativeSocketProtocolFamilies.pf_null)
_buffer_pos = 0
native = new NativeSocket.socket(new NativeSocketAddressFamilies.af_inet,
new NativeSocketTypes.sock_stream, new NativeSocketProtocolFamilies.pf_null)
_buffer.copy_to(ns, _buffer_length - _buffer_pos, _buffer_pos, 0)
_buffer = ns
end
_buffer.copy_to(ns, _buffer_length - _buffer_pos, _buffer_pos, 0)
_buffer = ns
end
# On error, returns an empty string and sets `error` appropriately.
fun recv(length: Int): String
do
# On error, returns an empty string and sets `error` appropriately.
fun recv(length: Int): String
do
var len = native.recvfrom(buf, length, 0, new NativeSocketAddrIn.nul)
if len == -1 then
error = new IOError.from_errno
return ""
end
var len = native.recvfrom(buf, length, 0, new NativeSocketAddrIn.nul)
if len == -1 then
error = new IOError.from_errno
return ""
end
fun recv_from(length: Int, sender: Ref[nullable SocketAddress]): String
do
var src = new NativeSocketAddrIn
fun recv_from(length: Int, sender: Ref[nullable SocketAddress]): String
do
var src = new NativeSocketAddrIn
var len = native.recvfrom(buf, length, 0, src)
if len == -1 then
var len = native.recvfrom(buf, length, 0, src)
if len == -1 then