maybe you can reverse use the sock.sin_port after the connection has been occured with port = ntohs(sock.sin_port) from the socket.
spielehelfer
Posts
-
Socket prblem -
Socket prblemsomething in the back of my brain said: "sock.sin_port = 0" would let the OS select the port....
-
Using _T() and L"" in UNICODE Projects? [modified]Be carefull with '' and "" ... can drive you into some problems. :)
-
Right click for open programYou mean a "right click" on the file in the windows explorer view, where you can select "open with" or similar the application? --> thats a registry "hack"
-
Sockets Programming QuestionWell this one is needed as far as I knnow to store the adress you want to listen, f.ex.
//adress buildup SOCKADDR_IN lSockAddr; memset(&lSockAddr,0, sizeof(lSockAddr)); lSockAddr.sin_family = AF_INET; lSockAddr.sin_port = htons(8500); lSockAddr.sin_addr.s_addr = INADDR_ANY;
and afterwards you can check if all initialize went OK withif(lSockAddr.sin_addr.s_addr ==INADDR_NONE) //error
-
Thread Colsing ProblemWell I left several part out, thats true. - I thought its well known whats able to fill 'params' with - the Threadobject would be deleted after the loop jumps out, what happens when the thread has ended (I didnt write it, ok). - that the Sleep() is no 100% secure statement for a threadchange ist true - to secure the application for deadlocks, there are several locking mechanism possible so secure shared variables. - WaitForSingleObject has the problem that it locks up the application that calls it if used tirect in a window creating code, thats why i used a loop. Well Im not a code guru, dont think Im one and also theres every time someone that knows more than me :)
-
Error when using CSocket with ThreadingOh interesting, someone else with CSocket and Thread probs.... Had lately also probs with CSocket and CAsyncSocket....sending works fine but no Messages were send/received so I was unable to receive ..... I went back to C based socket communication and there it works
-
Converting a UTF-8 Character in to its euuavalant Unicode NumberWideCharToMultiByte() MultiByteToWideChar() helps to convert 1byte -> 2byte and other way round data representation things
-
Thread Colsing Problem^^ yep if possible use a timer... otherwise by using a thread: load: ThreadRef = AfxBeginThread(Thread, ¶ms, THREAD_PRIORITY_BELOW_NORMAL, 0, CREATE_SUSPENDED); disable auto delete: ThreadRef->m_bAutoDelete = false; start Thread: ThreadRef->ResumeThread(); then use a global variable to signalize the thread to exit (in Thread func)
if(params->pDlg->m_WantExit){ return 1; }
and use a own method in the main function to clean up the threads, calld before ending, and also wait till they end.do{ Sleep(1); //jump to thread GetExitCodeThread(ThreadRef->m_hThread,&ExitCode); }while(ExitCode == STILL_ACTIVE);
this makes sure that the thread gets canceled correct on end of the main function. -
how to use stl?why dont u use the class CString?
-
Sizing-EndHmm when the resizing stops, the user as released the mouse... maybe you can catch this event and look everytime its called if there had been a resizement. Maybe by a "locking" variable in your "refresh Function" -> Mosedown -> lock enable refresh part not called -> Moseup -> lock release -> refresh/paint
-
Problem with CPropertySheet classHi, I've got some Problems with CPropertySheet in the development of a C++ application in emVC++. Problem is: I have a PropertySheet width 4 pages (all same size 260*92); but they all get cut of at the right side. So I startet do derive a class from CPropertySheet and overwrite the OnInit Method like in this project: Free size and extended styles in CPropertySheets This brought me a few Problems: - the
CPropertyPage* pppg = GetActivePage();
causes access violation so I changed it intoCPropertyPage* pppg = GetPage(0);
(curious from outside, in the dialog class i can use GetActivePage(), inside I only get a 0x0 pointer) - also thepppg->MapDialogRect(rcOriginal);
causes access violation and all other Methods that later on uses pppg too. This brings me down to the problem that I cannot read out the PropertyPage size on runtime and have to use fixed values to resize. so only these lines had been left from all the code:BOOL bResult = CPropertySheet::OnInitDialog(); ModifyStyleEx(0, WS_EX_TOOLWINDOW); CRect rcModified; //Tab GetTabControl()->GetWindowRect(rcModified); ScreenToClient(&rcModified); rcModified.right +=50; GetTabControl()->SetWindowPos( NULL, 0,0, rcModified.Width(), rcModified.Height(), SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE ); //Sheet GetWindowRect(rcModified); ScreenToClient(&rcModified); rcModified.right +=50; SetWindowPos( NULL, 0,0, rcModified.Width(), rcModified.Height(), SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE );
Anyone has an idea why I cannot acces the ActivePage() or also the work with the PropertyPage reference loaded by GetPage(0) causes access violations?