当前位置: 首页 > 文档资料 > Perl 入门教程 >

setsockopt

优质
小牛编辑
134浏览
2023-12-01

描述 (Description)

此函数在SOCKET上以指定的LEVEL设置套接字选项OPTNAME,其值为OPTVAL。 您将需要导入Socket模块以获取Tabl中显示的OPTNAME的有效值

语法 (Syntax)

以下是此函数的简单语法 -

setsockopt SOCKET, LEVEL, OPTNAME, OPTVAL

返回值 (Return Value)

此函数在失败时返回undef,在成功时返回1。

OPTNAME 	Description
SO_DEBUG 	Enable/disable recording of debugging information.
SO_REUSEADDR 	Enable/disable local address reuse.
SO_KEEPALIVE 	Enable/disable keep connections alive.
SO_DONTROUTE 	Enable/disable routing bypass for outgoing messages.
SO_LINGER 	Linger on close if data is present.
SO_BROADCAST 	Enable/disable permission to transmit broadcast messages.
SO_OOBINLINE 	Enable/disable reception of out-of-band data in band.
SO_SNDBUF 	Set buffer size for output.
SO_RCVBUF 	Set buffer size for input.
SO_TYPE 	Get the type of the socket (get only).
SO_ERROR 	Get and clear error on the socket (get only).
<!--

例子 (Example)

Following is the example code showing its basic usage −

When above code is executed, it produces the following result −

-->