调试套接字 c++ 代码并帮助我理解
Debugging a socket c++ code and help me understand
我有一个已经存在的代码(cuda c ++(,我想调试它,这在c ++中使用套接字,我不确定它到底在做什么以及如何能够链接到特定地址?请帮助我了解什么是ai_family
、ai_socktype
、ai_protocol
和其他手段?
int sockfd = socket(host_info->ai_family, host_info->ai_socktype, host_info->ai_protocol);
if (sockfd<0)
{
printf("can't create socketn");
return false;
}
if (connect(sockfd, host_info->ai_addr, host_info->ai_addrlen)<0)
{
printf("can't create connectionn");
return false;
}
你可以谷歌一下,MSDN有使用的定义和示例。Linux肯定有自己的帮助。只需寻找您需要的东西,因为有很多可能性,而且只有少数经常使用。
插座有多种选择。
地址版本:IPv4 和 IPv6。 套接字类型:UDP、TCP 等。
我相信也有非网络套接字,对吧?
每个选项都会彻底改变套接字需要执行的内容。
相关文章:
- 当套接字连接断开时检测C/C++Unix
- 通过套接字[TCP]传输数据 如何在C / C ++中打包多个整数并使用send() recv()传输数据
- 如何通过套接字将文本文件的内容从服务器发送到客户端
- 如何在C/C++中用FD_set Unix设置套接字文件描述符
- 套接字读取后,我在缓冲区中看到意外输入
- 如何在CPP中创建应该在Windows和Linux上运行的套接字?
- 我可以与 python 服务器而不是 c++ 客户端建立 tcp/ip 套接字吗?
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- WINAPI 注册应用程序重新启动时不清除打开的套接字
- (Winsock) UDP 接收工作正常,但同一套接字的发送失败
- MSG_WAITALL的套接字发送得到了 22 EINVAL
- C++套接字客户端到 Python 服务器未创建连接
- 在不知道套接字的情况下关闭网络连接
- C++套接字对不读/写父/子
- 非更新套接字消息
- SIGSEGV on Boost UDP 套接字关闭 - tcache_get at malloc.c.
- 将"uint8_t"(从套接字读取)隐式转换为"char"安全吗
- 当对套接字 send() 的同步调用由于连接另一端丢失而被阻止时,如何恢复?
- 调试套接字 c++ 代码并帮助我理解
- 需要帮助java到C++的ssl套接字