socket( AF_INET, SOCK_STREAM, IPPROTO_TCP )这个返回值表示什么意义
2个回答
展开全部
RETURN VALUE
On success, a file descriptor for the new socket is returned. On
error, -1 is returned, and errno is set appropriately.
ERRORS
EACCES Permission to create a socket of the specified type and/or pro-
tocol is denied.
EAFNOSUPPORT
The implementation does not support the specified address fam-
ily.
EINVAL Unknown protocol, or protocol family not available.
EINVAL Invalid flags in type.
EMFILE Process file table overflow.
ENFILE The system limit on the total number of open files has been
reached.
ENOBUFS or ENOMEM
Insufficient memory is available. The socket cannot be created
until sufficient resources are freed.
EPROTONOSUPPORT
The protocol type or the specified protocol is not supported
within this domain.
Other errors may be generated by the underlying protocol modules.
例子:
clientfd = socket(AF_INET, SOCK_STREAM, 0);
if (clientfd < 0) {
LOG_RECORD(LOG_ERR, "Create socket error.");
return -1;
}
ret = connect(clientfd, (struct sockaddr *)&host_addr, sizeof(host_addr));
On success, a file descriptor for the new socket is returned. On
error, -1 is returned, and errno is set appropriately.
ERRORS
EACCES Permission to create a socket of the specified type and/or pro-
tocol is denied.
EAFNOSUPPORT
The implementation does not support the specified address fam-
ily.
EINVAL Unknown protocol, or protocol family not available.
EINVAL Invalid flags in type.
EMFILE Process file table overflow.
ENFILE The system limit on the total number of open files has been
reached.
ENOBUFS or ENOMEM
Insufficient memory is available. The socket cannot be created
until sufficient resources are freed.
EPROTONOSUPPORT
The protocol type or the specified protocol is not supported
within this domain.
Other errors may be generated by the underlying protocol modules.
例子:
clientfd = socket(AF_INET, SOCK_STREAM, 0);
if (clientfd < 0) {
LOG_RECORD(LOG_ERR, "Create socket error.");
return -1;
}
ret = connect(clientfd, (struct sockaddr *)&host_addr, sizeof(host_addr));
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询