套接字问题 大家帮忙看看 谢谢了
// server.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include "server.h"
#include "winsock.h"
#pragma comment(lib, "ws2_32")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
WSADATA wsadata;
WORD ver = MAKEWORD(2,2);
WSAStartup(ver, &wsadata);
SOCKET server ;
char password[10] ;
server = socket(AF_INET, SOCK_STREAM, 0);
SOCKADDR_IN serveradd ;
serveradd.sin_family = AF_INET ;
serveradd.sin_port= htons(12345) ;
serveradd.sin_addr.S_un.S_addr = htonl(INADDR_ANY) ;
bind(server, (SOCKADDR*)&serveradd, sizeof(serveradd));
listen(server, 20);
SOCKET eds ;
while(true)
{
if( eds = accept(server, 0, 0)!=INVALID_SOCKET)
{
if (send(eds, password, sizeof(password), 0)!=SOCKET_ERROR) //问题在这 总是返回SOCKET_ERROR send不能发送 怎么回事啊?
{
cout << "等待密码验证\n" ;
}
}
}
}
以上是服务端的代码 问题已经标在注释上了