fatal error C1083: 无法打开包括文件:“stdafx.h”网上找了不少答案都不行,求高手解答
#include"stdafx.h"#include<stdlib.h>#include<Winsock2.h>#include<stdio.h>voidmain(){W...
#include "stdafx.h"
#include <stdlib.h>
#include <Winsock2.h>
#include <stdio.h>
void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 )
{
return;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||HIBYTE( wsaData.wVersion ) != 1 )
{ WSACleanup( );
return;}
SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);
SOCKADDR_IN addrSrv;
addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
addrSrv.sin_family=AF_INET;
addrSrv.sin_port=htons(6000);
bind(sockSrv,(const sockaddr*)&addrSrv,sizeof(SOCKADDR));
listen(sockSrv,5);
SOCKADDR_IN addrClient;
int len=sizeof(SOCKADDR);
while(1)
{
SOCKET sockCon=accept(sockSrv,(SOCKADDR*)&addrClient,&len);
char sendBuf[100];
sprintf(sendBuf,"This is server,Welcome%s",inet_ntoa(addrClient.sin_addr));
send(sockCon,sendBuf,strlen(sendBuf)+1,0);
char recvbuf[100];
recv(sockCon,recvbuf,strlen(recvbuf)+1,0);
printf("%s\n",recvbuf);
closesocket(sockCon);
}
system("PAUSE");
}
程序
求加QQ1410299153
用的是VC2008 展开
#include <stdlib.h>
#include <Winsock2.h>
#include <stdio.h>
void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 )
{
return;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||HIBYTE( wsaData.wVersion ) != 1 )
{ WSACleanup( );
return;}
SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);
SOCKADDR_IN addrSrv;
addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
addrSrv.sin_family=AF_INET;
addrSrv.sin_port=htons(6000);
bind(sockSrv,(const sockaddr*)&addrSrv,sizeof(SOCKADDR));
listen(sockSrv,5);
SOCKADDR_IN addrClient;
int len=sizeof(SOCKADDR);
while(1)
{
SOCKET sockCon=accept(sockSrv,(SOCKADDR*)&addrClient,&len);
char sendBuf[100];
sprintf(sendBuf,"This is server,Welcome%s",inet_ntoa(addrClient.sin_addr));
send(sockCon,sendBuf,strlen(sendBuf)+1,0);
char recvbuf[100];
recv(sockCon,recvbuf,strlen(recvbuf)+1,0);
printf("%s\n",recvbuf);
closesocket(sockCon);
}
system("PAUSE");
}
程序
求加QQ1410299153
用的是VC2008 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询