| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4600 人关注过本帖
标题:新手请教关于win7 64位环境下vc2008 socket编程的问题
只看楼主 加入收藏
meybeican
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-12-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
新手请教关于win7 64位环境下vc2008 socket编程的问题
代码如下:

#include "Hello.h"
#include "stdio.h"
#include "windows.h"
#include "winsock2.h"
#pragma comment (lib,"ws2_32")

Hello::Hello(void)
{
}

Hello::~Hello(void)
{
}

void ssocket()
{
   WSADATA wasData;
   WSAStartup(MAKEWORD(2,2),&wasData);

   SOCKET s = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
   sockaddr_in socketadd;
   socketadd.sin_family = PF_INET;
   socketadd.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
   socketadd.sin_port = htons(827);

   bind(s,(SOCKADDR*)&socketadd,sizeof(SOCKADDR));

   listen(s,1);

   SOCKADDR clientadd;

   int nSize = sizeo(SOCKADDR);
   SOCKET clientSock;
   clientSock = accept(s,(SOCKADDR*)&clientadd,nSize);

   send(clientSock,"hello client \r\n",strlen("hello client \r\n")+sizeof(char),NULL);

   closesocket(clientSock);
   closesocket(s);

   WSACleanup();
}

int main()
{
     ssocket();
    return 0;
}


报了一大堆错,请各位高手看看,是不是环境哪儿有问题呐,头文件都在报错,跪求指导啊

1>------ Build started: Project: hello, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>Hello.cpp
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(127) : warning C4005: 'AF_MAX' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(479) : see previous definition of 'AF_MAX'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(163) : warning C4005: 'SO_DONTLINGER' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(206) : error C2011: 'sockaddr' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(485) : see declaration of 'sockaddr'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(384) : error C2143: syntax error : missing '}' before 'constant'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(384) : error C2143: syntax error : missing ';' before 'constant'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(384) : error C2059: syntax error : 'constant'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(437) : error C2143: syntax error : missing ';' before '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(437) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(437) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(518) : warning C4005: 'IN_CLASSA' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(287) : see previous definition of 'IN_CLASSA'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(524) : warning C4005: 'IN_CLASSB' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(293) : see previous definition of 'IN_CLASSB'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(530) : warning C4005: 'IN_CLASSC' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(299) : see previous definition of 'IN_CLASSC'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(541) : warning C4005: 'INADDR_ANY' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(304) : see previous definition of 'INADDR_ANY'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(543) : warning C4005: 'INADDR_BROADCAST' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(306) : see previous definition of 'INADDR_BROADCAST'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(577) : error C2011: 'sockaddr_in' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(312) : see declaration of 'sockaddr_in'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(132) : error C2011: 'fd_set' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(68) : see declaration of 'fd_set'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(167) : warning C4005: 'FD_SET' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(102) : see previous definition of 'FD_SET'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(176) : error C2011: 'timeval' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(111) : see declaration of 'timeval'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(232) : error C2011: 'hostent' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(167) : see declaration of 'hostent'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(245) : error C2011: 'netent' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(180) : see declaration of 'netent'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(252) : error C2011: 'servent' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(187) : see declaration of 'servent'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(264) : error C2011: 'protoent' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(199) : see declaration of 'protoent'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(360) : error C2011: 'WSAData' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(322) : see declaration of 'WSAData'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(458) : error C2011: 'sockproto' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(494) : see declaration of 'sockproto'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(500) : error C2011: 'linger' : 'struct' type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(531) : see declaration of 'linger'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(513) : warning C4005: 'SOMAXCONN' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(544) : see previous definition of 'SOMAXCONN'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(542) : warning C4005: 'FD_READ' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(562) : see previous definition of 'FD_READ'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(545) : warning C4005: 'FD_WRITE' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(563) : see previous definition of 'FD_WRITE'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(548) : warning C4005: 'FD_OOB' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(564) : see previous definition of 'FD_OOB'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(551) : warning C4005: 'FD_ACCEPT' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(565) : see previous definition of 'FD_ACCEPT'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(554) : warning C4005: 'FD_CONNECT' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(566) : see previous definition of 'FD_CONNECT'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(557) : warning C4005: 'FD_CLOSE' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(567) : see previous definition of 'FD_CLOSE'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1527) : error C2375: 'accept' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(735) : see declaration of 'accept'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1548) : error C2375: 'bind' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(740) : see declaration of 'bind'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1567) : error C2375: 'closesocket' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(745) : see declaration of 'closesocket'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1586) : error C2375: 'connect' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(747) : see declaration of 'connect'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1607) : error C2375: 'ioctlsocket' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(752) : see declaration of 'ioctlsocket'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1628) : error C2375: 'getpeername' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(757) : see declaration of 'getpeername'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1649) : error C2375: 'getsockname' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(762) : see declaration of 'getsockname'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1672) : error C2375: 'getsockopt' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(767) : see declaration of 'getsockopt'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1693) : error C2375: 'htonl' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(774) : see declaration of 'htonl'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1710) : error C2375: 'htons' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(776) : see declaration of 'htons'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1728) : error C2375: 'inet_addr' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(778) : see declaration of 'inet_addr'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1745) : error C2375: 'inet_ntoa' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(780) : see declaration of 'inet_ntoa'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1763) : error C2375: 'listen' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(782) : see declaration of 'listen'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1781) : error C2375: 'ntohl' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(786) : see declaration of 'ntohl'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1798) : error C2375: 'ntohs' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(788) : see declaration of 'ntohs'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1818) : error C2375: 'recv' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(790) : see declaration of 'recv'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1843) : error C2375: 'recvfrom' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(796) : see declaration of 'recvfrom'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1869) : error C2375: 'select' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(804) : see declaration of 'select'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1893) : error C2375: 'send' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(811) : see declaration of 'send'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1918) : error C2375: 'sendto' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(817) : see declaration of 'sendto'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1944) : error C2375: 'setsockopt' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(825) : see declaration of 'setsockopt'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1966) : error C2375: 'shutdown' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(832) : see declaration of 'shutdown'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(1986) : error C2375: 'socket' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(836) : see declaration of 'socket'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2009) : error C2375: 'gethostbyaddr' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(843) : see declaration of 'gethostbyaddr'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2029) : error C2375: 'gethostbyname' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(848) : see declaration of 'gethostbyname'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2047) : error C2375: 'gethostname' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(850) : see declaration of 'gethostname'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2067) : error C2375: 'getservbyport' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(854) : see declaration of 'getservbyport'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2087) : error C2375: 'getservbyname' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(858) : see declaration of 'getservbyname'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2106) : error C2375: 'getprotobynumber' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(862) : see declaration of 'getprotobynumber'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2124) : error C2375: 'getprotobyname' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(864) : see declaration of 'getprotobyname'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2145) : error C2375: 'WSAStartup' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(868) : see declaration of 'WSAStartup'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2163) : error C2375: 'WSACleanup' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(872) : see declaration of 'WSACleanup'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2180) : error C2375: 'WSASetLastError' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(874) : see declaration of 'WSASetLastError'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2197) : error C2375: 'WSAGetLastError' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(876) : see declaration of 'WSAGetLastError'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2214) : error C2375: 'WSAIsBlocking' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(878) : see declaration of 'WSAIsBlocking'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2231) : error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(880) : see declaration of 'WSAUnhookBlockingHook'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2248) : error C2375: 'WSASetBlockingHook' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(882) : see declaration of 'WSASetBlockingHook'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2265) : error C2375: 'WSACancelBlockingCall' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(884) : see declaration of 'WSACancelBlockingCall'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2287) : error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(886) : see declaration of 'WSAAsyncGetServByName'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2314) : error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(894) : see declaration of 'WSAAsyncGetServByPort'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2340) : error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(902) : see declaration of 'WSAAsyncGetProtoByName'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2365) : error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(909) : see declaration of 'WSAAsyncGetProtoByNumber'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2390) : error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(916) : see declaration of 'WSAAsyncGetHostByName'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2417) : error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(923) : see declaration of 'WSAAsyncGetHostByAddr'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2440) : error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(932) : see declaration of 'WSACancelAsyncRequest'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(2461) : error C2375: 'WSAAsyncSelect' : redefinition; different linkage
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(934) : see declaration of 'WSAAsyncSelect'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(3910) : error C2059: syntax error : '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(3910) : error C2143: syntax error : missing ';' before '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winsock2.h(3910) : error C2059: syntax error : '}'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(8) : error C2143: syntax error : missing ';' before '{'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(8) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(70) : error C2079: 'wasData' uses undefined struct 'WSAData'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(71) : error C3861: 'WSAStartup': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(73) : error C3861: 'socket': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(73) : error C2440: 'initializing' : cannot convert from 'SOCKET (__stdcall *)(int,int,int)' to 'SOCKET'
1>        There is no context in which this conversion is possible
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(74) : error C2079: 'socketadd' uses undefined struct 'sockaddr_in'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(75) : error C2228: left of '.sin_family' must have class/struct/union
1>        type is 'int'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(76) : error C2228: left of '.sin_addr' must have class/struct/union
1>        type is 'int'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(76) : error C2228: left of '.S_un' must have class/struct/union
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(76) : error C2228: left of '.S_addr' must have class/struct/union
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(76) : error C3861: 'inet_addr': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(77) : error C2228: left of '.sin_port' must have class/struct/union
1>        type is 'int'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(77) : error C3861: 'htons': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(79) : error C3861: 'bind': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(81) : error C3861: 'listen': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(83) : error C2079: 'clientadd' uses undefined struct 'sockaddr'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(85) : error C2275: 'SOCKADDR' : illegal use of this type as an expression
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(1000) : see declaration of 'SOCKADDR'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(85) : error C3861: 'sizeo': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(87) : error C2440: '=' : cannot convert from 'SOCKET (__stdcall *)(SOCKET,sockaddr *,int *)' to 'SOCKET'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(87) : error C2440: '=' : cannot convert from 'SOCKET (__stdcall *)(SOCKET,sockaddr *,int *)' to 'SOCKET'
1>        There is no context in which this conversion is possible
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(87) : error C3861: 'accept': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(89) : error C3861: 'send': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(91) : error C3861: 'closesocket': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(92) : error C3861: 'closesocket': identifier not found
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\hello.cpp(94) : error C3861: 'WSACleanup': identifier not found
1>client.cpp
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(12) : error C2065: 'sockAddr_in' : undeclared identifier
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(12) : error C2146: syntax error : missing ';' before identifier 'sockAddr'
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(12) : error C2065: 'sockAddr' : undeclared identifier
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(13) : error C2065: 'sockAddr' : undeclared identifier
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(13) : error C2228: left of '.sin_addr' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(14) : error C2065: 'sockAddr' : undeclared identifier
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(14) : error C2228: left of '.sin_addr' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(14) : error C2228: left of '.S_un' must have class/struct/union
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(14) : error C2228: left of '.S_addr' must have class/struct/union
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(15) : error C2065: 'sockAddr' : undeclared identifier
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(15) : error C2228: left of '.sin_port' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\haoxy\documents\visual studio 2005\projects\hello\hello\client.cpp(17) : error C2065: 'sockAddr' : undeclared identifier
1>Generating Code...
1>Build log was saved at "file://c:\Users\haoxy\Documents\Visual Studio 2005\Projects\hello\hello\Debug\BuildLog.htm"
1>hello - 104 error(s), 17 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

搜索更多相关主题的帖子: comment include 
2013-12-09 15:44
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:20 
#pragma comment(lib, "Ws2_32.lib")??

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-12-09 22:20
ckandbzm
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-12-28
收藏
得分:0 
学习了,真的不错
2013-12-28 10:52
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:0 
明显定义错误。。。。。
又不是定义错误。
估计工程的原因#include <winsock2.h>
看看。。。。
2楼 版主,你这个回答。。。
编译 和 链接。。。你确定你了解过吗???

用心做一件事情就这么简单
2014-01-23 11:51
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
以下是引用小鱼儿c在2014-1-23 11:51:58的发言:

明显定义错误。。。。。
又不是定义错误。
估计工程的原因#include <winsock2.h>
看看。。。。
2楼 版主,你这个回答。。。
编译 和 链接。。。你确定你了解过吗???

你不明白错误?楼主打漏了 .lib

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2014-01-23 15:37
快速回复:新手请教关于win7 64位环境下vc2008 socket编程的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050651 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved