| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 684 人关注过本帖
标题:该程序编译失败
只看楼主 加入收藏
ds15fkcjj
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2012-12-8
结帖率:37.5%
收藏
已结贴  问题点数:2 回复次数:7 
该程序编译失败
如下程序用破解版VC6编译失败。
#include<stdio.h>
#include<winsock2.h>
#include<fstream>
#include<iostream>
using namespace sd;
void main()
{
int Client;
int Client2;
fstream Client2;
ofstream Client2;
Client2.open("clienthost.cfg");
Client2>>Client;
Client2.Close
SOCKET Sender;
InitWinsock();
struck sockaddr_in server;
int len =sizeof(server);
server.sin_family=AF_INET;
server.sin_port=htons(1037);
server.sin_addr.s_addr=inet_addr(%d,&Client);
Sender=socket(AF_INET,SOCK_DGRAM,0);
while(1)
printf("请输入要发送的数据,回车后将数据发送到 %d 计算机中。若要调出输入法,请同时按下Ctrl+空格键,或按下Ctrl+Shift。",&Client);
scanf("%s",buffer);
if(sendto(Sender,buffer,sizeof,buffer,0,(struct sockaddr*)&server,len)!=SOCKET_ERROR)
{
printf("发送成功!");
if(recvform(Sender,buffer,sizeofbuffer,0,(struct,sockaddr*)&server,&len)!=SOCKET_ERROR)
msgbox(NULL,buffer,"来自远程计算机发送的消息",MB_OK);
}
}
closesocket(socket1);
}
int Error;
WORD VersionRequested;
WSADATA Wsadata;
VersionRequested=MAKEWORD(2,2);
Error=WSAStartup(VersionRequested,&Wsadata);
if(Error!=0)
{
return FALSE;
}
else
{
if(LOBYTE=(Wsadata.wVersion)!=2||HIBYTE(Wsadata.wHighVersion)!=2)
{
WSACleanup();
return FALSE;
}
}
return TRUE;
}
搜索更多相关主题的帖子: 破解版 server include 1037 
2012-12-12 22:27
mmmmmmmmmmmm
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:8
帖 子:388
专家分:1809
注 册:2012-11-2
收藏
得分:0 
代码不全

根据编译错误来解决

我们的目标只有一个:消灭0回复!
while(1)
++money;
2012-12-12 22:28
深藏依旧
Rank: 2
等 级:论坛游民
帖 子:45
专家分:93
注 册:2012-12-8
收藏
得分:0 
错误很是多啊 using namespace std;都写成using namespace sd了  建议自己动手改一下

厚积薄发
2012-12-12 22:34
ds15fkcjj
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2012-12-8
收藏
得分:0 
#include<stdio.h>
#include<winsock2.h>
#include<fstream>  //文件处理头文件
#include<iostream>  //文件处理头文件
using namespace sd;
void main()
{
int Client;
int Client2;
fstream Client2;
ofstream Client2;
Client2.open("clienthost.cfg"); //读文件clienthost.cfg
Client2>>Client; //读文件到Client变量中,该变量为IP地址
Client2.Close  //关闭文件读取
SOCKET Sender;
InitWinsock();
struck sockaddr_in server;
int len =sizeof(server);
server.sin_family=AF_INET;
server.sin_port=htons(1037);
server.sin_addr.s_addr=inet_addr(%d,&Client);
Sender=socket(AF_INET,SOCK_DGRAM,0);
while(1)
printf("请输入要发送的数据,回车后将数据发送到 %d 计算机中。若要调出输入法,请同时按下Ctrl+空格键,或按下Ctrl+Shift。",&Client);
scanf("%s",buffer);  
if(sendto(Sender,buffer,sizeof,buffer,0,(struct sockaddr*)&server,len)!=SOCKET_ERROR)
{
printf("发送成功!");
if(recvform(Sender,buffer,sizeofbuffer,0,(struct,sockaddr*)&server,&len)!=SOCKET_ERROR)
msgbox(NULL,buffer,"来自远程计算机发送的消息",MB_OK); //对话框
}
}
closesocket(socket1);
}
int Error;
WORD VersionRequested;
WSADATA Wsadata;
VersionRequested=MAKEWORD(2,2);
Error=WSAStartup(VersionRequested,&Wsadata);
if(Error!=0)
{
return FALSE;
}
else
{
if(LOBYTE=(Wsadata.wVersion)!=2||HIBYTE(Wsadata.wHighVersion)!=2)
{
WSACleanup();
return FALSE;
}
}
return TRUE;
}
按照书上的UDPSOCKET示例代码来写的,不同之处在于添加了文件读取功能。
2012-12-12 22:34
ds15fkcjj
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2012-12-8
收藏
得分:0 
错误信息:
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: Clients - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP12.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/Clients.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Documents and Settings\Administrator\My Documents\CJJ\Clients\Clients.c"
]
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP12.tmp"
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP13.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/Clients.pdb" /debug /machine:I386 /out:"Debug/Clients.exe" /pdbtype:sept
".\Debug\Clients.obj"
]
Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP13.tmp"
<h3>Output Window</h3>
Compiling...
Clients.c
c:\documents and settings\administrator\my documents\vc6.0 完整绿色版\vc98\include\eh.h(32) : fatal error C1189: #error :  "eh.h is only for C++!"
执行 cl.exe 时出错.



<h3>Results</h3>
Clients.exe - 1 error(s), 0 warning(s)
</pre>
</body>
</html>
2012-12-13 15:56
huang1938120
Rank: 2
等 级:论坛游民
帖 子:51
专家分:41
注 册:2012-10-30
收藏
得分:0 
呃 算我打酱油的
2012-12-13 16:07
crystall
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:7
帖 子:184
专家分:809
注 册:2012-12-1
收藏
得分:2 
程序代码:
#include "stdafx.h"

#include<stdio.h>
#include<winsock2.h>
#include<fstream>   //文件处理头文件
#include<iostream>  //文件处理头文件

//套接字
#include <Winsock2.h>
#pragma comment(lib, "Ws2_32.lib")

using namespace std;

void InitWinsock()
{
    WORD wVersionRequested;
    WSADATA wsaData;

    wVersionRequested = MAKEWORD( 2, 2 );

    WSAStartup( wVersionRequested, &wsaData );
}

void main()
{
    int Client;

    fstream  fClient2;
    ofstream oClient2;

    fClient2.open("clienthost.cfg"); //读文件clienthost.cfg
    fClient2 >> Client;                //读文件到Client变量中,该变量为IP地址
    fClient2.close();                //关闭文件读取
   
    SOCKET Sender;

    sockaddr_in server;

    int len = sizeof(server);
    server.sin_family=AF_INET;
    server.sin_port=htons(1037);
    //server.sin_addr.s_addr = inet_addr((char*)&Client);
    server.sin_addr.s_addr = inet_addr("127.0.0.1");

    InitWinsock();

    Sender = socket(AF_INET,SOCK_DGRAM,0);

    char buffer[MAXBYTE] = {0};

    while(1)
    {
        printf("请输入要发送的数据,回车后将数据发送到 %d 计算机中。若要调出输入法,请同时按下Ctrl+空格键,或按下Ctrl+Shift。",&Client);
        scanf("%s", buffer); 
        if(sendto(Sender, buffer, MAXBYTE, 0, (sockaddr*)&server, len) != SOCKET_ERROR)
        {
            printf("发送成功!");
        }

        if(recvfrom(Sender,buffer,sizeof(buffer),0,(sockaddr*)&server, &len) != SOCKET_ERROR)
        {
            ::MessageBox(NULL, buffer,"来自远程计算机发送的消息",MB_OK); //对话框
        }
    }

    closesocket(Sender);
    Sender = INVALID_SOCKET;
}
2012-12-13 16:20
crystall
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:7
帖 子:184
专家分:809
注 册:2012-12-1
收藏
得分:0 
程序代码:
你这代码是你自己写的吗? 好犀利啊。
我这里贴出部分代码供你参考,欢迎大家探讨,指错。

void CClientDlg::OnConnect()
{
    if(m_hSocket != INVALID_SOCKET)
    {
        return;
    }

    //socket
    m_hSocket =    ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(m_hSocket == INVALID_SOCKET)
    {
        return;
    }

    //更新EDIT_IP =>CString  m_csServerIp
    //更新EDIT_PORT =>CString  m_hdServerPort
    UpdateData(TRUE);

    m_Server_addrin.sin_addr.s_addr = inet_addr(m_csServerIp);
    m_Server_addrin.sin_family = AF_INET;
    m_Server_addrin.sin_port = htons(m_hdServerPort);

    //发送请求连接
    if(MySendCommandPack(CMD_REQUEST_CONNECT, m_hSocket, m_Server_addrin) == FALSE)
    {
        return;
    }

    //接收线程
    AfxBeginThread(MyRecvThreadProc, NULL);

    return;
}

//sendto
BOOL CClientDlg::MySendCommandPack(IN UINT uCmd,
                                   IN SOCKET hSocket,
                                   IN sockaddr_in addr_in)
{
    m_PackCommand.uCmd = uCmd;

    if(hSocket == INVALID_SOCKET)
    {
        return FALSE;
    }

    int nSendRet = sendto(hSocket,
                          (char*)&m_PackCommand,
                          sizeof(m_PackCommand),
                          0,
                          (sockaddr *)&addr_in,
                          sizeof(sockaddr_in));

    if (nSendRet == SOCKET_ERROR)
    {
        return FALSE;
    }

    return TRUE;
}

UINT CClientDlg::MyRecvPackHeader(IN LPVOID lpParament)
{
    int nLen = sizeof(sockaddr_in);
    sockaddr_in client_addrin = {0};
    char szBuff[MAX_BUFF] = {0};
    UINT uCmd = 0;

    int nRet = recvfrom(m_hSocket, szBuff, MAX_BUFF, 0, (sockaddr*)&client_addrin, &nLen);
    if((nRet == 0) || (nRet == SOCKET_ERROR) )
    {
        //缓冲区不够
        if(WSAGetLastError() == WSAEMSGSIZE)
        {
            Sleep(1);
        }
        else
        {
            g_pDlg->PostMessage(WM_COMMAND, BTN_UNCONNECT, NULL);

            return RESULT_FALSE;
        }
    }
    else
    {
        uCmd = szBuff[0];

        switch(uCmd)
        {
        //连接 成功
        case CMD_CONNECT_SUCCESSFUL:
            {
                (GetDlgItem(BTN_CONNECT))->EnableWindow(FALSE);
                (GetDlgItem(BTN_UNCONNECT))->EnableWindow(TRUE);

                //开启定时发送心跳包
                SetTimer(SEND_HEARTBEATPACK, 30000, (TIMERPROC)NULL);

                return RESULT_OK;
            }
        //服务器已关闭
        case CMD_SERVER_CLOSE:
            {
                g_pDlg->PostMessage(WM_COMMAND, BTN_UNCONNECT, NULL);

                return RESULT_OK;
            }
        }
    }

    return 0;
}
2012-12-13 16:25
快速回复:该程序编译失败
数据加载中...
 
   



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

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