Home  Contents

rawio:connect

Rawio Core4 Lua Event System

SYNOPSIS

flag = handle:connect(remote_address, remote_port)

DESCRIPTION

Connect this socket to a remote socket listening to the port remote_port at the machine with the address remote_address.

For TCP sockets, this attempts to make a full TCP connection to the peer. On success, data can be exchanged full-duplex.

For UDP sockets, this simply configures the socket to exchange data with a single peer. No data is exchanged by calling rawio:connect() itself. After a connect call, the generic rawio:read() and rawio:write() commands can be used with the socket which now solely exchange data with the configured peer.

RETURN VALUE

On success, returns true. On failure, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

EXAMPLE

>  > 
sock = rawio:socket("TCP") success = sock:connect("1.2.3.4", 80)

SEE ALSO