求大神解答我程序哪里有错误
#include "afx.h"#include <conio.h>
#include<stdio.h>
#include <winsock2.h>
#pragma comment(lib,"WS2_32.lib")
int winmain()
{
WSADATA wsd;
SOCKET s;
char buf[1024];
if(WSAStartup(MAKEWORD(2, 2),&wsd)!=0)
{
return -1;//失败
}
s=socket(AF_INET,SOCK_DGRAM,0);
if (s==INVALID_SOCKET)
{
WSACleanup();
return -1;
//创建套接字失败
}
SOCKADDR_IN servAddr;
servAddr.sin_family=AF_INET;
servAddr.sin_addr.s_addr=inet_addr("10.184.15.63");
servAddr.sin_port=htons(2000);
if(bind(s,(SOCKADDR*)&servAddr,sizeof(SOCKADDR_IN))==SOCKET_ERROR)
{
closesocket(s);
WSACleanup();
return -1;
//绑定套接字失败
}
int nServAddrlen=sizeof(servAddr);
ZeroMemory(buf,sizeof(buf));
CString ss="TimeNow";
strcpy(buf,ss);
SOCKADDR_IN clientAddr;
clientAddr.sin_family=AF_INET;
clientAddr.sin_addr.s_addr=inet_addr("10.184.15.63");
clientAddr.sin_port=htons((short)5000);
int nClientlen=sizeof(clientAddr);
if(sendto(s,buf,sizeof(buf),0,(SOCKADDR*)&clientAddr,nClientlen)==SOCKET_ERROR)
{
closesocket(s);
WSACleanup();
return -1;
//向服务器发送数据失败
}
memset(buf,0,1024);
if (recvfrom(s,buf,sizeof(buf),0,(SOCKADDR*)&servAddr,&nServAddrlen)==SOCKET_ERROR)
{
closesocket(s);
WSACleanup();
return -1;
//接收数据失败
}
SYSTEMTIME systime;
memcpy(&systime,buf,16);
SetLocalTime(&systime);//设置本地与服务器时间同步。
closesocket(s);
WSACleanup();
_getch();
return 0;
}
在VS2013里面调试通过,但显示不出程序框,一闪而过,跪求解释原因,急求!!!!