C++ header files for UDP in Windows?(Windows 中 UDP 的 C++ 头文件?)
问题描述
我有一个通过 UDP 协议发送数据的 linux 应用程序.它使用这些头文件:
I have a linux applications which sends data over UDP protocol. It uses these header files:
#include <stdio.h>
/* standard C i/o facilities */
#include <stdlib.h>
/* needed for atoi() */
#include <unistd.h>
/* defines STDIN_FILENO, system calls,etc */
#include <sys/types.h> /* system data type definitions */
#include <sys/socket.h> /* socket specific definitions */
#include <netinet/in.h> /* INET constants and stuff */
#include <arpa/inet.h> /* IP address conversion stuff */
#include <netdb.h>
#include <string.h> /* for string and memset etc */
/* gethostbyname */
#include <iostream>
#include <fstream>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
我想制作我的应用程序的 WIndows 版本.但是上面的一些头文件在 WINdows 中不起作用,尤其是 UDP 的.
I want to make a WIndows version of my app. But some of the above header files do not work in WIndows, especially those for UDP.
我应该在 Windows (Visual Studio 2010) 中替换哪些头文件?
Which header files should I substitute them for in Windows (Visual Studio 2010)?
更新:
好的,所以我的标题现在看起来像这样:
Ok, so my header now looks like this:
#include <iostream>
#include <fstream>
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <winsock2.h>
我在尝试编译时收到此错误(以及许多其他类似错误):
I get this error when trying to compile (and many other similar errors):
Error 13 error C2011: 'fd_set' : 'struct' type redefinition c:program files (x86)microsoft sdkswindowsv7.0aincludewinsock2.h 132 1 Client
推荐答案
在编译时,您需要使用 Winsock2.h 而不是 Unix 头文件.
At compile-time, you need to use Winsock2.h instead of the Unix headers.
在链接时,包含 ws2_32.lib 以提供到所需系统 DLL 的链接.
At link-time, include ws2_32.lib to provide linkage to the required system DLL.
这篇关于Windows 中 UDP 的 C++ 头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Windows 中 UDP 的 C++ 头文件?
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
