现在的位置: 首页 > 综合 > 正文

套接字API(一)socket函数

2013年12月09日 ⁄ 综合 ⁄ 共 257字 ⁄ 字号 评论关闭

一 功能:

*socket():creates a  endpoint for communication and return a descriptor.

二 格式:

(一)int socket(int family,int type,int protocol)

*成功:返回非负描述符,在Unix系统上套接字描述符用文件描述符实现。出错:返回-1.


(二)参数说明:

*family:指明协议族。如下图:


*type:指明套接字类型。如下图:


protocol:指明协议。例如:IPPROTO_TCP:TCP协议;IPPROTO_UDP:UDP传输协议。


抱歉!评论已关闭.