How to send c++ lists via sockets to a remote server and write those info to a file using PHP -
i want achieve following:
- send data above c++ source php script (that create) on remote server via sockets (can wether winhttp or regular sockets, no curl or other 3rd party libraries)
the php parse data , write file. there can multiple files, files need numbered.
#include <windows.h> #include <stdio.h> #include <tchar.h> #include <psapi.h> #include <dirent.h> #include <iostream> #include <string> #pragma comment( lib, "psapi.lib" ) using namespace std; void printprocessnameandid( dword processid ) // list of running processes { tchar szprocessname[max_path] = text("<unknown>"); handle hprocess = openprocess( process_query_information | process_vm_read, false, processid ); if (null != hprocess ) { hmodule hmod; dword cbneeded; if ( enumprocessmodules( hprocess, &hmod, sizeof(hmod), &cbneeded) ) { getmodulebasename( hprocess, hmod, szprocessname, sizeof(szprocessname)/sizeof(tchar) ); } } _tprintf( text("%s (pid: %u)\n"), szprocessname, processid ); closehandle( hprocess ); } int main( void ) { dword aprocesses[1024], cbneeded, cprocesses; unsigned int i; if ( !enumprocesses( aprocesses, sizeof(aprocesses), &cbneeded ) ) return 1; cprocesses = cbneeded / sizeof(dword); cout<<"\n\n"; cout<<"get list of running processes\n\n"; ( = 0; < cprocesses; i++ ) { if( aprocesses[i] != 0 ) { printprocessnameandid( aprocesses[i] ); } } /*get list of directories in root folder of c++ */ cout<<"\n\n"; cout<<"get list of directories in root folder of c++ (not recursive)\n\n"; dir *dirstr = null; string filepath; cout<<"enter c++ root directory path: "; cin>>filepath; dirstr = opendir(filepath.c_str()); dirent *nextfile = null; while ((nextfile = readdir(dirstr))!=null) { if (nextfile->d_name[0] != '.') cout<<nextfile->d_name<<endl; } return 0; }
how can send list of processes , directories using sockets remote server , how able write info file using php ?
i've searched here on many questions related to:
- sending c++ parameters using sockets
- store c++ parameters in php files
but none helped me out. ideas ?
Comments
Post a Comment