Click here to Skip to main content
16,004,761 members

Comments by Dhanasundhari (Top 15 by date)

Dhanasundhari 28-Jul-11 5:37am View    
ok. sir . i will do that.

there is an any way to send the vector via socket communication in c++
Dhanasundhari 28-Jul-11 5:36am View    
The error is the memecpy_s() is a undeclared varriable..
i use both the header files (string.h and memory.h)
but it producing the same error. There is an any other method to serialize the data ..
Dhanasundhari 28-Jul-11 3:36am View    
#include "stdafx.h"
#include <memory.h>
#include <windows.h>
#include <winsock2.h>
#include <iostream.h>
#include <lm.h>
#include <vector>
#include <string>
#include <memory.h>
using namespace std;
struct ClientInformation
{
string sCliName;
int iPlatId;
int iMajor;
int iType;
int iMinor;
};

class cClient
{
private:
DWORD dwLevel;
DWORD dwPrefMaxLen;
LPSERVER_INFO_101 pBuf;
DWORD dwEntriesRead;
DWORD dwTotalEntries;
DWORD dwServerType;
LPTSTR pszDomainName;
NET_API_STATUS nStatus;
WSADATA wsaData;
DWORD dwResumeHandle;
char cszBuf[200];
SOCKET ClientSocket;
int iTemp;
string str;
public:
cClient()
{
dwLevel = 101;
dwPrefMaxLen = MAX_PREFERRED_LENGTH;
pBuf = NULL;
dwEntriesRead = 0;
dwTotalEntries = 0;
dwServerType = SV_TYPE_SERVER;
pszDomainName = NULL;
dwResumeHandle = 0;

}

void FindDomainSystem()
{
ClientInformation *StructObj;
vector <clientinformation> *myvec;
WSAStartup(MAKEWORD(2,2), &wsaData);
nStatus = NetServerEnum(NULL,dwLevel,(LPBYTE *) & pBuf,dwPrefMaxLen,
&dwEntriesRead,&dwTotalEntries,dwServerType,
NULL, &dwResumeHandle);
myvec = new vector <clientinformation>();

if(nStatus == NERR_Success)
{
cout<<"The NetServerEnumeration sucessfuly "<<"\n";
cout<<"The total entires is "<<dwEntriesRead<<"\n\n";
for(int i=1; i<= dwEntriesRead;i++)
{

memset(cszBuf,0,sizeof(cszBuf));

sprintf( cszBuf, "%S", pBuf->sv101_name );
cout<<"\nThe server name "<<cszBuf<<"\n";
StructObj->sCliName.erase();
StructObj->sCliName.append(cszBuf);
cout<<"The Platform id of the system is "<<pBuf->sv101_platform_id<<"\n";
StructObj->iPlatId = pBuf->sv101_platform_id;
cout<<"The type of system running is "<<pBuf->sv101_type<<"\n";
StructObj->iType = pBuf->sv101_type;
cout<<"The major version of the system is "<<pBuf->sv101_version_major<<"\n";
StructObj->iMajor = pBuf->sv101_version_major;
cout<<"The minor version of the system is "<<pBuf->sv101_version_minor<<"\n";
StructObj->iMinor = pBuf->sv101_version_minor;
send(ClientSocket,(char*)&StructObj,sizeof(StructObj),0);
myvec->push_back(*StructObj);
pBuf++;
}
}
else
{
cout<<"\nThe Net Enumeration producing Error\n";
}
cout<<"\n\n\n\nThe vector data\n";
display(myvec);

}
void display(vector <clientinformation> *my)
{
BYTE *pData = NULL;
if(my)
{
int i = my->size();
if(i)
{
pData = new BYTE(i*sizeof(ClientInformation));
ClientInformation *psData = (ClientInformation*)pData;
for(int i1=0;i1<i;i++)
{
="" memcpy_s(psdata[i1],sizeof(clientinformation),&my-="">at(i1),sizeof(ClientInformation)); //prodcing error in that place.. what i want to do now...
}
}

//int icount = my
}

}


};
int main(int argc, char* argv[])
{

cClient o;
o.FindDomainSystem();
return 0;
}

thats is the code i build sir.. but it producing error sir..
what i want to do now..
Dhanasundhari 28-Jul-11 3:31am View    
ok.. Thanks sir..
Dhanasundhari 28-Jul-11 3:06am View    
How to de-serialize that sir. in my client side