我为客户端和服务器创建了一个 C 程序,用于将数据从一台计算机传输到另一台计算机。以下代码
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <iostream.h>
void main()
{
int sockfd;
struct sockaddr_in saddr;
char *xyz,xyz1;
sockfd = socket(AF_INET,SOCK_STREAM,0);
saddr.sin_family = AF_INET;
saddr.sin_port=htons(5001);
saddr.sin_addr.s_addr = inet_aton("192.168.0.254");
connect(sockfd,(struct sockaddr *)&saddr,sizeof(saddr));
fgets(xyz);
write(sockfd,xyz,sizeof(xyz));
read(sockfd,xyz1,sizeof(xyz1));
fputs(xyz);
close(sockfd);
}
但它在 trubo c++ 3.0 IDE 中显示以下错误
UNABLE TO OPEN INCLUDE FILE 'SYS/SOCKET.H'
UNABLE TO OPEN INCLUDE FILE 'NETINET/IN.H'
UNABLE TO OPEN INCLUDE FILE 'ARPA/INET.H'