|
oh, that's okay I just include comdef.h and everything's fine
|
|
|
|
|
I'm trying to create a clients/server program, which only one server and lots of clients..
so I get the computer name using GetComputerName( ) as a server name pipe.
I had no problem creating name pipe when
lpszPipename = "\\\\.\\pipe\\mynamepipe";
but when I changed lpszPipename, it doesn't work..
LPCTSTR lpszPipename = "\\\\computer1\\pipe\\mynamepipe";
<br />
LPCTSTR lpszPipename = "\\\\computername\\pipe\\mynamepipe";<br />
<br />
HANDLE hPipe;<br />
<br />
hPipe = CreateNamedPipe( <br />
lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
NMPWAIT_USE_DEFAULT_WAIT,
NULL);
<br />
if (hPipe == INVALID_HANDLE_VALUE) <br />
{<br />
MessageBox("CreatePipe failed"); <br />
return ;<br />
}<br />
What am I doing wrong?
|
|
|
|
|
The MSDN says:
lpName
[in] Pointer to the null-terminated string that uniquely identifies the pipe. The string *MUST* have the following form:
\\.\pipe\pipename
I suggest you put your "computername" preceding the "pipename" name part.
GuimaSun
www.nexsun.com.br
|
|
|
|
|
The problem is that both server.exe and client.exe are communicating very well if and only if they both are on the same machine.
For examplle. there are 3 machines, c1,c2,and c3.
The server.exe is running on c2 and the client is running on each machine.
(note: both server.exe and client.exe are on the network drive.)
only the client on c2 is communicating with the server because to the client is on the same machine that the server.exe is running.
the other clients on c1 and c3 are not able to communicate with the server.exe.
Namepipe is used to commnunication between client and server.
CreateNamepipe(), "\\\\.\\pipe\\c2", is used by server.
CreateFile(),"\\\\.\\pipe\\c2", is used by client.
ReadFile() and WriteFile() are used to communication between client and server.
I thought I have to change the string ""\\\\.\\pipe\\c2", to "\\\\c2\\pipe\\c2", so client can find the server and talk. but I cant' even createNamepipe using above string ("\\\\c2\\pipe\\c2")
If I used the old string "\\\\.\\pipe\\c2" then client on the other machine can't find server.
what am i missing?
|
|
|
|
|
I am doing a multi threaded application that involves exchange of data.
ONE UI THREAD
AND 3 WORKER THREADS.PLS LET ME HOW TO EXCHANGE THE DATA BETWEEN THESE 3 WORKER THREADS.
FOR EX:THE FIRST THREAD WILL GIVE THE SECOND THREAD THE 2 NUMBERS AS ARGUEMENTS.the second thread should return the first thread the sum.
Pls help
YKUT
|
|
|
|
|
Use PostMessage() to communicate between them.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi there,
If I add a CArray such as CByteArray to a struct like so:
<br />
typedef struct DATAGRAM<br />
{<br />
CByteArray pkt_data;
} DATAGRAM;<br />
and then try and assign something of type DATAGRAM to type DATAGRAM i get the following compile error:
C2558: struct 'DATAGRAM' : no copy constructor available or copy constructor is declared 'explicit'
I know this is because because CByteArray is of dynamic type so I need to provide a copy constructor. So my question is do I need to provide one for DATAGRAM or do I really need to provide one for CByteArray and if so could somebody post a code snippet to help me out?
Cheers
Packetlos
|
|
|
|
|
isn't it because you use a struct instead of a class ?
i know C++ enlarge structures capabilities, but i wonder if that's possible...
TOXCCT >>> GEII power
|
|
|
|
|
You don't need to provide one for CByteArray if you provide one for DATAGRAM (that does not rely on CByteArray having a copy constructor)
|
|
|
|
|
Thanks toxcct and antlers,
toxcct was right that there in as far as I can see a way to provide a constructor for the struct, therefore I converted it to a class and used CByteArray's .Copy() to provide the assignment.
|
|
|
|
|
There is little difference between a class and a structure. The only difference is that the default protection is private for a class and public for a structure.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
that's what i was thinking, but in another side, i did never see struct with member functions...
so, here was my doubt.
TOXCCT >>> GEII power
|
|
|
|
|
Remember that a struct in C++ is a class that defaults to public access and a normal class defaults to private access. Since DATAGRAM has a dynamic member it does require a copy constructor:
struct DATAGRAM
{
CByteArray pkt_data;
DATAGRAM(DATAGRAM& dg)
{
pkt_data.Copy(dg.pkt_data);
}
};
Note: I did not use a typedef because it is not needed in C++.
Good Luck!
Now if the blasted power does not go out again, you'll get this message!
INTP
|
|
|
|
|
I recommend you use a more modern design of container, perhaps std::vector<unsigned char> . These containers provide a copy constructor so that the compiler default copy constructor for your class will work.
I don't think you should be having to work out how to copy a CByteArray efficiently, or even correctly.
Paul
|
|
|
|
|
I want to store listbox strings in to a file with serialization and load strings from this file with serialization.
Mehdi Hosseinpour
|
|
|
|
|
Something like:
CString str;
CFile file;
file.Open(..., CFile::modeWrite);
CArchive ar(&file, CArchive::store);
for (int x = 0; x < listbox.GetCount(); x++)
{
listbox.GetText(x, str);
ar << str;
}
ar.Close();
file.Close();
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Might want to ar << listbox.GetCount(); first.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Of course. I never indicated it was a complete working code example, hence the "Something like" qualifier. When typing this stuff from memory, small details often get omitted.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
Hi All.
The problem I am facing is a bit different. Even I do not know, whether the problem is related to Embedded programming or can be solved with VC++ MFC itself.
I want to send and recieve data between my vc++ application and a USB device. Thats the main issue.
Can anyone tell from where to start or if anyone can help me with the coding that should be done...I will be very thankfull for that help.
Thanks and regards,
Pankaj Bhalla
pankajbhalla@mantraonline.com
Pankaj Bhalla
Consultant - VC++
|
|
|
|
|
Which USB Device you are talking about.
Please Clarify.
|
|
|
|
|
Hello Darshan.
Thanks for your consideration and time. Actually, the USB device is itself, under the process of creation. So, not sure about the device, but if you can then please tell me general steps we have to take to make it possible. I mean the articles or any other source from where I can get more information about this issue. If you can the please tell me the MFC classes we can use or any info. about MFC and USB devices.
Thanks and Regards,
Pankaj Bhalla
|
|
|
|
|
Where can I download GDI+ librarys and headers?
|
|
|
|
|
You can get it from:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
I think it's in the core SDK part.
|
|
|
|
|
I've got a char array
<br />
char *vec;<br />
and i allocate memory for a number of elemets
<br />
vec = (char*) malloc ((sizeof(char))*(number_of_elemets));<br />
i do that in main.
then i call a free function
<br />
free_mem (vec);<br />
the function code is:
<br />
void free_mem (char *vec,number_of _elements)<br />
{ <br />
for (i=0;i<(number_of _elements);i++)<br />
{<br />
free (vec[i]);<br />
}<br />
}<br />
it gives me errors
what's wrong?
thanks!!
|
|
|
|