#ifndef _FreeEIM_UI
#define _FreeEIM_UI
#define _FreeEIM_UI
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class FreeEIM
{
public:
void ShowCommand(); // 显示提示信息;
FreeEIM();
~FreeEIM();
};
#endif // _FreeEIM_UI
{
public:
void ShowCommand(); // 显示提示信息;
FreeEIM();
~FreeEIM();
};
#endif // _FreeEIM_UI
#include "StdAfx.h"
#include "freeeim_udp.h"
#include "stdemdef.h"
#include "freeeim_udp.h"
#include "stdemdef.h"
FreeEIM_UDP::FreeEIM_UDP()
{
WSADATA data;
WSAStartup(0x0202, &data);
m_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (INVALID_SOCKET == m_sock)
{
printf("FreeEIM_UDP::FreeEIM_UDP socket creating error.");
return;
}
}
{
WSADATA data;
WSAStartup(0x0202, &data);
m_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (INVALID_SOCKET == m_sock)
{
printf("FreeEIM_UDP::FreeEIM_UDP socket creating error.");
return;
}
}
FreeEIM_UDP::~FreeEIM_UDP()
{
closesocket(m_sock);
WSACleanup();
}
{
closesocket(m_sock);
WSACleanup();
}
void FreeEIM_UDP::SendData(char *szIP, char* pData, int nLen)
{
if(pData == NULL)
{
printf(_T("FreeEIM_UDP::SendData Message is empty"));
return;
}
SOCKADDR_IN sin;
sin.sin_addr.s_addr = inet_addr(szIP);
sin.sin_family = AF_INET;
sin.sin_port = htons(MSG_SEND_PORT);
sin.sin_addr.s_addr = inet_addr(szIP);
sin.sin_family = AF_INET;
sin.sin_port = htons(MSG_SEND_PORT);
if (sendto(m_sock, pData, nLen, 0, (PSOCKADDR)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf(_T("FreeEIM_UDP::SendData sendto failed"));
return;
}
}
{
printf(_T("FreeEIM_UDP::SendData sendto failed"));
return;
}
}