socket
plugin helper creates various types of socket instances.socket
plugin helper does not manage the lifecycle of the socket. User must close the socket when it is no longer needed.socket_create(proto, host, port, **kwargs, &block)
proto
: protocol type. { :tcp
, :udp
, :tls
}host
: host name or IP addressport
: port numberkwargs
: extra options. For more details, see methods below.block
: customize socketsocket_create_tcp(host, port, **kwargs, &block)
host
: hostname or IP addressport
: port numberkwargs
: extra optionsresolve_name
: if true
, resolve the hostnamenonblock
: if true
, use non-blocking I/Olinger_timeout
: the timeout (seconds) to set SO_LINGER
recv_timeout
: the timeout (seconds) to set SO_RECVTIMEO
send_timeout
: the timeout (seconds) to set SO_SNDTIMEO
send_keepalive_packet
: if true
, enable TCP keep-alive via SO_KEEPALIVE
connect_timeout
: the timeout for socket connect. When the connectionErrno::ETIMEDOUT
is raised.send_keepalive_packet
Use Casetrue
to send_keepalive_packet
, you also need to configure keep-alive related kernel parameters:socket_create_udp(host, port, **kwargs, &block)
host
: host name or IP addressport
: port numberkwargs
: extra optionsresolve_name
: if true
, resolve the hostnameconnect
: if true
, connect to hostnonblock
: if true
, use non-blocking I/Olinger_timeout
: the timeout (seconds) to set SO_LINGER
recv_timeout
: the timeout (seconds) to set SO_RECVTIMEO
send_timeout
: the timeout (seconds) to set SO_SNDTIMEO
socket_create_tls(host, port, **kwargs, &block)
host
: host name or IP addressport
: port numberkwargs
: extra optionsversion
: set TLS version :TLSv1_1
or :TLSv1_2
. (default: :TLSv1_2
)ciphers
: set the list of available cipher suites. (default:"ALL:!aNULL:!eNULL:!SSLv2"
)insecure
: if true
, set TLS verify mode NONE
verify_fqdn
: if true
, validate the server certificate for the hostnamefqdn
: set FQDNenable_system_cert_store
: if true
, enable system default cert storeallow_self_signed_cert
: if true
, allow self-signed certificatecert_paths
: files contain PEM-encoded certificatesprivate_key_path
: set the client private key pathprivate_key_passphrase
: set the client private key passphrasecert_thumbprint
: set the certificate thumbprint for searching from Windows system certstorecert_logical_store_name
: set the certificate logical store name on Windows system certstorecert_use_enterprise_store
: if true
, enable to use certificate enterprise store on Windows system certstorekwargs
socket