|
ccpptrain wrote: Please answer the followings :-
Do I get a toffee?
found at bash.org
[kernx]|.|.|.|.|.|.|.|
[kernx]sorry, wrong window
[beox33]say me why in the f*ck will you type that in any window
|
|
|
|
|
hi i am newbie...
i am a bit confused in socket programming.
my question is..
how can we communicate thru sockets between two different Ips as these two ip are have their internal IP and external IPs.
suppose that communication shud be between A and B.and A and B are having their internal and external IPs.
1. how the server(A) shud listen (ok it will listen to port x)?.if the client(B) connect to external IP of A..will that each to the server A?
2.if server (A) sends a message to Client (B) on B`s external IP will that reach the client B?
any one please pull me out of this confusion . plz point out if i am wrong or suggetst me how can i wright socket application ( chat for examaple) between these two IPs those of each are having two IP`( internal and external).
--Thanks in advance.
hi
|
|
|
|
|
A Socket needs an IPAddress to communicate with its another peer.
1. It doesnt care whether it is External (PublicIP) or Internal (LAN)(hope my
interpretation of internal and external is right) it is handled by the DNSserver (publicIP) or your LAN GateWay.
2. Once the Connect--listen-- accept sequence is over, you can exchange messages between any two connected sockets.
regards,
haribabu
|
|
|
|
|
namithakathi wrote: how can we communicate thru sockets between two different Ips as these two ip are have their internal IP and external IPs.
Let's start inside the LAN, here your two peers communicate using the internal LAN IP addresses.
It gets a little bit more difficult when you communicate outside the LAN and the internet IP address (external IP address) is different to the LAN IP address (internal IP address). Generally two peers on the internet have to communicate via their external IP adresses, typically the router or the proxy does a kind of network-address-translation for you. For example if your internal IP address is 192.168.1.1 it could from the outside look like as you would have an external IP address 87.164.52.42. This network-address-translation often works automaticaly for the outgoing traffic (depends on your network setup), but it usually does not work automatically for incoming traffic (internet to LAN).... aka "firewalled computer".
Hope this helps for a start.
|
|
|
|
|
Once all thread started from the main thread. I have put the follwing wait message
in main thread to handle the child thread.Means until completed all the child threds Main thread must be wait.
for that I had put.
WaitForMultipleObjects(2, hThread, FALSE, INFINITE);
will it stop the messagepumping ?
because when thread reach at the following line .
<br />
SendMessage(hwndCmbProfile,CB_GETCURSEL,0,0);<br />
The application does stop the working .In Task manger it shown application not responding.
Is WaitForMultipleObjects affect on os message pumping??????
why the application get hang??
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: will it stop the messagepumping ?
If you don't start any new thread, your application has only one thread. It means that if you do something that takes a lot of time, your application will not respond during this time, because the message loop is in the same thread. Thus, if you wait for something in the main thread, your application won't respond (unable to process messages) until the wait is terminated and until you are able to process messages once again.
|
|
|
|
|
Firstly this line looks funny:
WaitForMultipleObjects(2, hThread, FALSE, INFINITE);
If hThread is thread HANDLE , as the Hungarian prefix suggests, then this should not compile. It looks like you're just waiting on one HANDLE . I'd guess hThread is a pointer to an array of HANDLE s: if this is the case the "h" prefix is confusing and will throw programmers that are aware of Hungarian prefixes.
Secondly, no message pump is running so the SendMessage in the worker thread will (and should) block. What you need is the MsgWaitForMultipleObjects function. Look in the ATL source code in the function AtlWaitWithMessageLoop for an example of its usage.
Steve
|
|
|
|
|
Stephen Hewitt wrote: I'd guess hThread is a pointer to an array of HANDLEs:
You are right sir ,
this is an array of HANDLES.
Plese look at here sir,
<br />
for(...)<br />
{<br />
<br />
<big>hThread[i] = (HANDLE ) _beginthreadex(NULL, 0, &Thread, l, 0, &tid)</big>}<br />
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Messages sent to a window must be processed by the thread that created the window. When a worker thread calls SendMessage() , it blocks until the message handler returns. Since the message is going to a window (assuming it was created by the main thread, which is uaually the case), the thread that has to handle the message is blocked and can't run, so you've created a deadlock.
You also have a bug in the call to WaitForMultipleObjects() - you say you're passing 2 handles, but only providing one.
|
|
|
|
|
Thank you sir,
How can I stop the deadlock situation? and child therad SendMessage to the window.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
You should avoid the use of SendMessage() between threads; if the receiving thread is not processing messages your application will deadlock.
Use PostMessage() instead.
Read more here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Grate !
Thanks! But my Thread application passes through some function where I every next step ,I have used the GUI messaging so now how can i handle that situation.
means fetching the values from the different control like combobox ,static text, listview during the thread is runing.
But thank you very much,
I will try it for PostMessage.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
As Stephen suggested above, AtlWaitWithMessageLoop() is one way to have a thread wait and still be able to process messages. It's the method I use.
|
|
|
|
|
sir,
I have found the help for that and I am satisfy with this answer but could you guide me where should i write this function?
I mean in my Mainthread or the successive function call from the Mainthread.( )
suppose ,
e.g.
<br />
for(....)<br />
{<br />
hThread[i]=(HANDLE ) _beginthreadex(NULL, 0, &Thread, l, 0, &tid);<br />
}
here ????? where should I call and where should I defined ?
<br />
unsigned __stdcall Thread(void* pArguments )<br />
{ <br />
HRESULT hr=NULL;<br />
struct argument_list *Lparam= (argument_list *)pArguments ;<br />
Package pkg;<br />
static int threadID;<br />
threadID++; <br />
{<br />
hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lparam->Host,Lparam->UserID,Lparam->InitPackageRequest,Lparam->ScriptFile,Lparam->Port,Lparam->hList,Lparam->_ProtectSet,Lparam->hWndinoutfiledir,Lparam->hwndEncrypt);<br />
}<br />
if(hr==S_OK)<br />
{ <br />
MessageBox(0,L"thread gone finished" ,L"therad",0);<br />
_endthreadex( 0 ); <br />
}<br />
<br />
<br />
threadID--; <br />
return 0;<br />
}
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Hi,
I am looking for windows api for finding out that
Whether a system is connected to Primary domain controller or its a local workstation?
If i am logged on to a domain controller i would like to know the domain name?
And if i am on a local machine then i would like to know about the computer name?
I tried GetComputerName but it doesn't give the domain controller Domain name in case of domain.
I want to somehow know if its on a domain or not??
Regards,
UI.
|
|
|
|
|
Dear umar cool,
Please find code for your question ....Thanks for giving me a good question to answer...
Senior guys... Please forgive me if I wrote a stupid code....
int EnumAllComputers()
{
LPSERVER_INFO_101 pBuf = NULL;
LPSERVER_INFO_101 pTmpBuf;
DWORD dwLevel = 101;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwTotalCount = 0;
DWORD dwServerType = SV_TYPE_SERVER; // all servers
DWORD dwResumeHandle = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
DWORD i;
//
// Call the NetServerEnum function to retrieve information
// for all servers, specifying information level 101.
//
nStatus = NetServerEnum((LPCSTR)pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
dwServerType,
NULL,
&dwResumeHandle);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
//
// Loop through the entries and
// print the data for all server types.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
fprintf(stderr, "An access violation has occurred\n");
break;
}
//printf("\tPlatform: %d\n", pTmpBuf->sv101_platform_id);
wprintf(L"\tName: %s\n", pTmpBuf->sv101_name);
//printf("\tVersion: %d.%d\n",
// pTmpBuf->sv101_version_major,
// pTmpBuf->sv101_version_minor);
printf("\tType: %d", pTmpBuf->sv101_type);
//
// Check to see if the server is a domain controller;
// if so, identify it as a PDC or a BDC.
//
/*SV_TYPE_WORKSTATION
SV_TYPE_SERVER
SV_TYPE_SQLSERVER
SV_TYPE_DOMAIN_CTRL
SV_TYPE_DOMAIN_BAKCTRL
SV_TYPE_TIME_SOURCE
SV_TYPE_AFP
SV_TYPE_NOVELL
SV_TYPE_DOMAIN_MEMBER
SV_TYPE_PRINTQ_SERVER
SV_TYPE_DIALIN_SERVER
SV_TYPE_XENIX_SERVER
SV_TYPE_SERVER_UNIX
SV_TYPE_NT
SV_TYPE_WFW
SV_TYPE_SERVER_MFPN
SV_TYPE_SERVER_NT
SV_TYPE_POTENTIAL_BROWSER
SV_TYPE_BACKUP_BROWSER
SV_TYPE_MASTER_BROWSER
SV_TYPE_DOMAIN_MASTER
SV_TYPE_SERVER_OSF
SV_TYPE_SERVER_VMS
SV_TYPE_WINDOWS
SV_TYPE_DFS
SV_TYPE_CLUSTER_NT
SV_TYPE_TERMINALSERVER
SV_TYPE_CLUSTER_VS_NT
SV_TYPE_DCE
SV_TYPE_ALTERNATE_XPORT
SV_TYPE_LOCAL_LIST_ONLY
SV_TYPE_DOMAIN_ENUM */
if (pTmpBuf->sv101_type & SV_TYPE_DOMAIN_CTRL)
{
wprintf(L" (PDC)");
}
if (pTmpBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL)
{
wprintf(L" (BDC)");
}
if(pTmpBuf->sv101_type & SV_TYPE_WORKSTATION)
{
wprintf(L" (WS)");
}
wprintf(L"\tComment: %s\n\n", pTmpBuf->sv101_comment);
printf("\n");
//
// Also print the comment associated with the server.
//
pTmpBuf++;
dwTotalCount++;
}
// Display a warning if all available entries were
// not enumerated, print the number actually
// enumerated, and the total number available.
if (nStatus == ERROR_MORE_DATA)
{
fprintf(stderr, "\nMore entries available!!!\n");
fprintf(stderr, "Total entries: %d", dwTotalEntries);
}
printf("\nEntries enumerated: %d\n", dwTotalCount);
}
}
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated buffer.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}
|
|
|
|
|
Hi All
i want to get ID of controls used in CommonDlg box used. For exp i want ID of Open File text used in FileOpen Dlg box.Because i want to change font of all controls used in FileOpen Dlg box,so for this i required ID of controls.
Thanks in Advance
Atool
|
|
|
|
|
M. Atul wrote: i want to get ID of controls used in CommonDlg box used.
Those are in dlgs.h .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
is it right to say that preprocessor directives is
#include<iostream.h>
and
preprocessor is a character
#
|
|
|
|
|
The preprocessor is a program that takes a source file and does things to it before the compiler sees the file. Directives are instructions to the preprocessor telling it what to do. More info here: clickety[^]
|
|
|
|
|
Hi
Does anyone know how to prevent self assignment of object.
E.g If I have a class A,
A a;
a = a; // how to prevent this
|
|
|
|
|
|
ragavan wrote: a = a; // how to prevent this
What do you mean "prevent"? You want a compiler error?
If you just don't want the assignment to happen you can create an assignment operator and check if the right hand side value s address == this and do not perform the assignment.
led mike
|
|
|
|
|
You probably also want to prevent the copy constructor. I guess your question is regarding manual memory management, classes that handle memory/resources might need a decent copy constructor and an assignment operator (or alternatively a prevention of shallow copy).
For details please see boost::noncopyable and the Law of the Big Two.
In my class designs I sometimes take the easy way and just use 'noncopy' to prevent the shallow copy (which also means users can't make a copy of the objects, which really is fine for some classes). But sometimes you actually want this feature and then I implement both copy contructor and assignment operator (with a check for accidental self assignment).
Hope it helps,
M
|
|
|
|
|
Hi all
I posted a message days before when I got an error message " program too big to fit in memory " while executing a binary . When I ran depends.exe on the problematic exe to my surprise I found that "at least one of the files are not Win32" ! . A quick question to my collegue who asked me to run this exe confirmed that he had sent me an exe intended for linux environment !
My question is : why did not I get a direct message like "non windows exe" or something like that ?
Why this "too big to fit in memory" message which misled me to beleive I might have some RAM issue/page file issue etc ...?
redindian
|
|
|
|