none
vs2010开发网络程序的问题 RRS feed

  • 问题

  • 有一段很简单的代码:

    const char *psz = "192.168.0.79";
     m_addr.sin_family = AF_INET;
     m_addr.sin_addr.S_un = inet_addr(psz); //这行有错
     m_addr.sin_port = htons(nPort);

    提示错误为:

    1>c:\documents and settings\administrator\桌面\server\client\mysocket.cpp(133): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'unsigned long' (or there is no acceptable conversion)
    1>          c:\program files\microsoft sdks\windows\v7.0a\include\inaddr.h(27): could be 'in_addr::<unnamed-type-S_un> &in_addr::<unnamed-type-S_un>::operator =(const in_addr::<unnamed-type-S_un> &)'
    1>          while trying to match the argument list '(in_addr::<unnamed-type-S_un>, unsigned long)'

    这个提示看得我不明不白, 网上也没有找到答案, 问问大家


    xiao

    2012年5月10日 2:44

答案

全部回复