网上查了半天,好多都是重复的,以下是我根据网上的代码,自己调试后解决的
以下内容,我是在虚拟机上 嵌入式 Linux上测试通过的,服务器端程序一大把,随便百度下就可以用了
客户端程序,我研究了,代码如下,注意 IPV6 地址,接口设备,端口需要修改
网上好多例子都没有提到 这个接口设备
接口设备你就是运行客户端程序的网卡
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <net/if.h>
#include <errno.h>
#define MAXBUF 1024
int main(int argc, char *argv[])
{
int iFd;
char arrcBuffer[MAXBUF + 1];
char *pcIPV6 = "fe80::dd56:57f3:2b88:54cb";
char *pcDev = "eth1";
int iPort = 5000;
printf("PAR: IPV6=%s DEV=%s PORT=%d\r\n Len = %d\r\n",pcIPV6, pcDev, iPort);
//if (argc < 3)
//{
//