// WinMacSocket.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "socket.h"
#include <iostream>
#include <string>
char sendBuf[] = "GET /StableWSDiscoveryEndpoint/schemas-xmlsoap-org_ws_2005_04_discovery HTTP/1.1\r\n\r\n";
char recvBuf[4096];
int _tmain(int argc, _TCHAR* argv[])
{
WSScocket socket;
if(socket.Init() == 0)
{
if (!socket.Create(AF_INET,SOCK_STREAM,IPPROTO_IP))
{
return -1;
}
if(!socket.Connect("150.245.177.13",80))
{
return -1;
}
int sendCount = socket.Send(sendBuf,sizeof(sendBuf),0);
std::string receive;
int recvBytes;
do
{
recvBytes = socket.Recv(recvBuf,sizeof(recvBuf),0);
if(recvBytes == SOCKET_ERROR || recvBytes == 0) // 0 means socket close.
{
break;
}
receive += std::string(recvBuf);
std::cout<<recvBuf<<std::endl;
} while (recvBytes > 0);
socket.Close();
socket.Clean();
}
return 0;
}
LCL_data原创于CSDN blog,转载请注明。
719




被折叠的 条评论
为什么被折叠?



