我是靠谱客的博主 潇洒蜜蜂,最近开发中收集的这篇文章主要介绍socket 函数 setsockopt()用法,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

资料来源: 微软MSDN在线帮助

setsockopt(s, level, optname, optval, optlen) 函数
https://msdn.microsoft.com/library/windows/desktop/ms740476.aspx

level = SOL_SOCKET

optname编码TypeDescription
SO_BROADCASTBOOLConfigures a socket for sending broadcast data.
SO_CONDITIONAL_ACCEPTBOOLEnables incoming connections are to be accepted or rejected by the application, not by the protocol stack.
SO_DEBUGBOOLEnables debug output. Microsoft providers currently do not output any debug information.
SO_DONTLINGERBOOLDoes not block close waiting for unsent data to be sent. Setting this option is equivalent to setting SO_LINGER with l_onoff set to zero.
SO_DONTROUTEBOOLSets whether outgoing data should be sent on interface the socket is bound to and not a routed on some other interface. This option is not supported on ATM sockets (results in an error).
SO_GROUP_PRIORITYintReserved.
SO_KEEPALIVEBOOLEnables sending keep-alive packets for a socket connection. Not supported on ATM sockets (results in an error).
SO_LINGERLINGERLingers on close if unsent data is present.
SO_OOBINLINEBOOLIndicates that out-of-bound data should be returned in-line with regular data. This option is only valid for connection-oriented protocols that support out-of-band data. For a discussion of this topic, see Protocol Independent Out-Of-band Data.
SO_RCVBUFintSpecifies the total per-socket buffer space reserved for receives.
SO_REUSEADDRBOOLAllows the socket to be bound to an address that is already in use. For more information, see bind. Not applicable on ATM sockets.
SO_EXCLUSIVEADDRUSEBOOLEnables a socket to be bound for exclusive access. Does not require administrative privilege.
SO_RCVTIMEODWORDSets the timeout, in milliseconds, for blocking receive calls.
SO_SNDBUFintSpecifies the total per-socket buffer space reserved for sends.
SO_SNDTIMEODWORDThe timeout, in milliseconds, for blocking send calls.
SO_UPDATE_ACCEPT_CONTEXTintUpdates the accepting socket with the context of the listening socket.
PVD_CONFIGService Provider DependentThis object stores the configuration information for the service provider associated with socket s. The exact format of this data structure is service provider specific.

详细参数

最后

以上就是潇洒蜜蜂为你收集整理的socket 函数 setsockopt()用法的全部内容,希望文章能够帮你解决socket 函数 setsockopt()用法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部