我是unix域套接字的新手,所以我尝试了beej的客户端和服务器代码,网址是:http://beej.us/guide/bgipc/html/multi/unixsock.html
服务器“工作”,但客户端在调用"connect“函数时给我一个错误。我得到了:“无效参数”错误。
有什么建议吗?
发布于 2015-12-29 20:24:28
在创建客户端套接字时尝试memset
struct sockaddr_un sin;
memset(&sin, 0, sizeof(sin));发布于 2018-06-14 05:04:25
我在这个教程中也遇到了同样的问题,问题在:
len = strlen(remote.sun_path) + sizeof(remote.sun_family);该赋值缺少sun_path末尾的空字符,因此您只需在右侧的表达式中添加一个:
len = strlen(remote.sun_path) + sizeof(remote.sun_family) + 1;在我的例子中,对connect的调用成功完成了这一更改。
https://stackoverflow.com/questions/34462052
复制相似问题