net/socket.eh

Client sockets. More...

use "net/socket.eh"

Types

type SecureSocket < Socket;
type Socket < StreamConnection;

Functions

def SecureSocket.get_secinfo(): SecInfo;
def SecureSocket.new(host: String, port: Int): SecureSocket;
def Socket.get_delay(): Bool;
def Socket.get_host(): String;
def Socket.get_keepalive(): Bool;
def Socket.get_linger(): Int;
def Socket.get_localhost(): String;
def Socket.get_localport(): Int;
def Socket.get_port(): Int;
def Socket.get_rcvbuf(): Int;
def Socket.get_sndbuf(): Int;
def Socket.new(host: String, port: Int): Socket;
def Socket.set_delay(on: Bool);
def Socket.set_keepalive(on: Bool);
def Socket.set_linger(linger: Int);
def Socket.set_rcvbuf(size: Int);
def Socket.set_sndbuf(size: Int);

Description

A client socket (or just "socket") is an endpoint for communication between two machines.

Simple example

// creating new connection to the server
var socket = new Socket("example.com", 79)
// setting options
socket.linger = 5
// sending something to the server
var out = socket.open_output()
out.println("Hello, server")
out.close()
// receiving something from the server
var in = socket.open_input()
var ch = 0
while (ch != EOF) 
  ch = in.read()

in.close()
// closing connection
socket.close()

Type details

type Socket < StreamConnection;
Client socket.

type SecureSocket < Socket;
SSL client socket.

Function details

def Socket.new(host: String, port: Int): Socket;
Creates new socket connection to the specified host and port.

def Socket.get_host(): String;
Returns remote host to which this socket is bound.

def Socket.get_port(): Int;
Returns remote port to which this socket is bound.

def Socket.get_localhost(): String;
Returns local host to which this socket is bound.

def Socket.get_localport(): Int;
Returns local port to which this socket is bound.

def Socket.get_delay(): Bool;
Tests whether this socket uses Nagle algorithm for small buffer operations.

def Socket.set_delay(on: Bool);
Sets socket option for the small buffer writing delay.

def Socket.get_keepalive(): Bool;
Tests whether KEEPALIVE feature turned on or not.

def Socket.set_keepalive(on: Bool);
Enables or disables KEEPALIVE feature of this socket.

def Socket.get_linger(): Int;
Returns a linger time of this socket, in seconds.

def Socket.set_linger(linger: Int);
Sets the linger time to wait in seconds before closing a connection with pending data output. Setting the linger time to zero disables the linger wait interval.

def Socket.get_sndbuf(): Int;
Returns size of the sending buffer for this socket.

def Socket.set_sndbuf(size: Int);
Sets size of the sending buffer for this socket.

def Socket.get_rcvbuf(): Int;
Returns size of the receiving buffer for this socket.

def Socket.set_rcvbuf(size: Int);
Sets size of the receiving buffer for this socket.

def SecureSocket.new(host: String, port: Int): SecureSocket;
Creates new secure connection to the specified host and port.

def SecureSocket.get_secinfo(): SecInfo;
Returns security information about this connection.