Click here to Skip to main content
16,004,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProblem with Activex Control property pages Pin
Sreenivas00320-May-10 21:21
Sreenivas00320-May-10 21:21 
Questioncall standard-draw of a control Pin
baerten20-May-10 21:10
baerten20-May-10 21:10 
AnswerRe: call standard-draw of a control Pin
Code-o-mat20-May-10 21:58
Code-o-mat20-May-10 21:58 
GeneralRe: call standard-draw of a control Pin
baerten20-May-10 22:41
baerten20-May-10 22:41 
GeneralRe: call standard-draw of a control Pin
Code-o-mat20-May-10 23:06
Code-o-mat20-May-10 23:06 
QuestionSend and Receive Problem Pin
Member 365375120-May-10 20:53
Member 365375120-May-10 20:53 
AnswerRe: Send and Receive Problem Pin
Richard MacCutchan20-May-10 21:19
mveRichard MacCutchan20-May-10 21:19 
GeneralRe: Send and Receive Problem Pin
Member 365375120-May-10 21:41
Member 365375120-May-10 21:41 
hi friend,

After sending i want wait for acknowledgement(RecieveThread).

Sendthread and recievethread individual Threads...

Example:
1. 10 clients connected to my Communicator....
2. I want to take associated client information(packets) from database i.e 10 or 100 packets
i want sent proper client and wait for acknowledgment.
After receiving acknowledgment i want sent another packet to corresponding client.
3. i want to all the clients like this...

note : Socket Handler stored in Map<clientid,sockethandler>;


UINT RecieveThread(LPVOID pParam)
{
AfxSocketInit();
CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam;
bool bRun = true;
SOCKET * pCurrentHandle;
CSocket pSocket;
char pBuf[4096];
CWinThread * pCurrentThread;
pCurrentThread = AfxGetThread();
pCurrentHandle = &hClinetHandle;
pSocket.Attach(hClinetHandle);
for(int i=0;i<4096;i++)
pBuf[i] = '\0';
int len;
while(bRun)
{
if(pSocket.Receive(pBuf,4096)>0)
{
len = sizeof(pBuf);
for( int i=0; i<len; i++ )
Dlg->ActionScanReceivedByte(pBuf[i]);
}
}
CliThreadList.RemoveAt(CliThreadList.Find(pCurrentThread));
pSocket.ShutDown(2);
pSocket.Close();
CliHandleList.RemoveAt(CliHandleList.Find(pCurrentHandle));

return 0;
}








UINT Sendthread(LPVOID pParam)
{
AfxSocketInit();
CSolusServerDlg *Dlg= (CSolusServerDlg*)pParam;
bool bRun = true;
SOCKET * pCurrentHandle;
CSocket pSocket;
char pBuf[4096];
CWinThread * pCurrentThread;
pCurrentThread = AfxGetThread();
pCurrentHandle = &hClinetHandle;
pSocket.Attach(hClinetHandle);

vecUploadValues AcfManagementData;

for(int i=0;i<4096;i++)
pBuf[i] = '\0';
int len;
FILE *fpUpload;
char date [10];
char time [15];
SYSTEMTIME st;
char* CStrTrim = new char[1024];
unsigned char *l_uca_Buffer;
unsigned char l_uca_ActualData[1024];
unsigned char l_uca_Buffer1[2048];
unsigned char *cConverationBuffer;
CString strTemp;
char cstrTemp[512];
CDBFile objDB;
CSocket *pSocketSent;
while(bRun)
{
for(IteratorMap = mapControllerHandler.begin(); IteratorMap != mapControllerHandler.end() ;IteratorMap++)
{
char strControllerID[10];
char strControllerIID[10];

int ControllerId = (*IteratorMap).first;
sprintf(strControllerID,"%06d ", ControllerId);
memset(strControllerIID,0,sizeof(strControllerIID));
objDB.GetControllerID(strControllerID,strControllerIID);
objDB.GetData(strControllerIID);
AcfManagementData = objDB.GetUploadValues();

pSocketSent = (*IteratorMap).second;

for(int i =0; i < AcfManagementData.size(); i++)
{
fpUpload = fopen("..\\LogFiles/ControllerLogFile.txt","a");

strTemp = AcfManagementData[i].cUploadValueString;

m_gobjDB->SetCommandData(AcfManagementData[i].cVActionValueString);

strcpy(cstrTemp,strTemp);

int len = strlen(cstrTemp);

l_uca_Buffer = (unsigned char*)cstrTemp;

memset( l_uca_ActualData, 0, sizeof( l_uca_ActualData) );

int unsigned iplen = StringtoCSV(l_uca_Buffer,len ,l_uca_ActualData);

(*IteratorMap).second->Send(l_uca_ActualData, iplen, 0 );

GetSystemTime(&st);

sprintf(date,"%d/%d/%d",st.wDay,st.wMonth,st.wYear);

sprintf(time,"%d:%d:%d:%d",st.wHour,st.wMinute,st.wSecond,st.wMilliseconds);

cConverationBuffer = CSVtoString(l_uca_ActualData,iplen);

fprintf(fpUpload,"%s %s| Sent | <%s>\n", date,time,cConverationBuffer);

fclose(fpUpload);

Sleep(1000);




}
}
}
CliThreadList.RemoveAt(CliThreadList.Find(pCurrentThread));
pSocket.ShutDown(2);
pSocket.Close();
CliHandleList.RemoveAt(CliHandleList.Find(pCurrentHandle));
return 0;
}



please help anybody...
GeneralRe: Send and Receive Problem Pin
Richard MacCutchan21-May-10 2:57
mveRichard MacCutchan21-May-10 2:57 
AnswerRe: Send and Receive Problem Pin
CPallini20-May-10 21:34
mveCPallini20-May-10 21:34 
GeneralRe: Send and Receive Problem Pin
Member 365375120-May-10 22:46
Member 365375120-May-10 22:46 
GeneralRe: Send and Receive Problem Pin
Iain Clarke, Warrior Programmer20-May-10 23:11
Iain Clarke, Warrior Programmer20-May-10 23:11 
QuestionRe: Send and Receive Problem Pin
David Crow21-May-10 3:05
David Crow21-May-10 3:05 
QuestionHow to track rename sheet event in Excel ? Pin
Gaurav171020-May-10 20:38
Gaurav171020-May-10 20:38 
QuestionExtract System's register's value by usiong 'C' language Pin
kushMuchaal20-May-10 18:39
kushMuchaal20-May-10 18:39 
AnswerRe: Extract System's register's value by usiong 'C' language Pin
Aescleal20-May-10 20:11
Aescleal20-May-10 20:11 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
kushMuchaal20-May-10 22:53
kushMuchaal20-May-10 22:53 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
kushMuchaal20-May-10 23:14
kushMuchaal20-May-10 23:14 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
kushMuchaal20-May-10 23:55
kushMuchaal20-May-10 23:55 
AnswerRe: Extract System's register's value by usiong 'C' language Pin
Aescleal21-May-10 1:01
Aescleal21-May-10 1:01 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
kushMuchaal21-May-10 1:57
kushMuchaal21-May-10 1:57 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
Aescleal21-May-10 2:27
Aescleal21-May-10 2:27 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
kushMuchaal21-May-10 2:44
kushMuchaal21-May-10 2:44 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
Richard MacCutchan21-May-10 3:08
mveRichard MacCutchan21-May-10 3:08 
GeneralRe: Extract System's register's value by usiong 'C' language Pin
David Crow21-May-10 3:08
David Crow21-May-10 3:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.