[Top]
Stdio
Stdio.File
|
Method Stdio.File()->open_socket()
- Method
open_socket
int(0..1) open_socket(int|void port, string|void addr, int|string|void family_hint)
- Method
open_socket
int open_socket(int|string|void port, string|void address, int|string|void family_hint)
- Description
This makes this file into a socket ready for connections. The reason
for this function is so that you can set the socket to nonblocking
or blocking (default is blocking) before you call connect() .
- Parameter port
If you give a port number to this function, the socket will be
bound to this port locally before connecting anywhere. This is
only useful for some silly protocols like FTP. The port can
also be specified as a string, giving the name of the service
associated with the port.
- Parameter address
You may specify an address to bind to if your machine has many IP
numbers.
- Parameter family_hint
A protocol family for the socket can be specified. If no family is
specified, one which is appropriate for the address is automatically
selected. Thus, there is normally no need to specify it. If you
do not want to specify a bind address, you can provide the address
as a hint here instead, to allow the automatic selection to work
anyway.
- Returns
This function returns 1 for success, 0 otherwise.
- See also
connect() , set_nonblocking() , set_blocking()
|