|
Hello, How can i use Lpt Capture on Windows 98 to capture lpt1 port data sended from dos application.
Thank's for your help.
|
|
|
|
|
Hi all ! I'm working at chat client/server likes yahoo. I have some trouble while sending a file to server and then distributes to others client.
Here is my code : On client
void CSimpleChatClientDlg::OnBnClickedButton1()
{
CFileDialog FileDialog(TRUE,
"*.*",
NULL,
OFN_HIDEREADONLY,
"Any Files (*.*)|*.*||");
if(FileDialog.DoModal() == IDOK)
{
UpdateData(TRUE);
CString PathName ="SHARE:ALL:" + FileDialog.GetPathName();
int Len=PathName.GetLength();
char* sendBuff=new char[Len+1];
strcpy(sendBuff,LPCTSTR(PathName));
send(sClient,(char*)&Len,sizeof(Len),0);
send(sClient,(char*)sendBuff,Len,0);
long nRead = 0;
BYTE byBuffer[BUFFER_SIZE];
CString strPath = FileDialog.GetPathName();
CFile myFile;
myFile.Open(strPath, CFile::modeRead | CFile::typeBinary);
long fileLen = myFile.GetLength();
send(sClient,(char*)&fileLen,sizeof(fileLen),0);
int count = 0;
while (true)
{
nRead = myFile.Read( byBuffer, BUFFER_SIZE );
if(nRead > 0)
{
if(nRead < BUFFER_SIZE)
send(sClient,(char*)&byBuffer,fileLen,0);
else
send(sClient,(char*)&byBuffer,BUFFER_SIZE,0);
}
else
break;
}
myFile.Close();
UpdateData(FALSE);
delete sendBuff;
}
}
On the Server
if(des_name.Compare("SHARE")==0)
{
i=Cbuff.Find(':');
des_name=Cbuff.Left(i);
mess=Cbuff.Right(Cbuff.GetLength() - i - 1);
if(des_name.Compare("ALL")==0)
{
CFile file;
file.Open(mess,CFile::modeWrite | CFile::typeBinary);
long lenFile=recv(sock.sk,buffer,buffLength,0);
long nfilerecv=0;
while(nfilerecv < lenFile)
{
nfilerecv += recv(sock.sk,buffer,buffLength,0);
}
m_msgString+=name_array[i_send];
m_msgString+=":";
m_msgString+=mess;
m_msgString+="\r\n";
UpdateData(FALSE);
}
else
UpdateData(FALSE);
delete buffer;
return;
}
I have send the exact len of the file but i can not receive the file on server. Is there anyone can help me !
|
|
|
|
|
Looking at your server code above you seem to have some lines missing. You also say "I have some trouble while sending", but we have no real idea what trouble; try explaining your problem in some more detail rather than expecting us to analyse your code without really knowing what we are looking for.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Honestly, i have no idea for receiving data from client. Although i can send the byte of the file, but set up buffer to receive file is ... The code from server site is just like the code i use to transfer text messages . If s.o could help me on that. I really appreciate.
Thanks !
P/s . I used winsock2 library to do this project, not CSocket likes some projects that had proble likes me before.
|
|
|
|
|
As I said before look at your server code; this is what you have:
while(nfilerecv < lenFile)
{
nfilerecv += recv(sock.sk,buffer,buffLength,0);
}
m_msgString+=name_array[i_send];
m_msgString+=":";
m_msgString+=mess;
m_msgString+="\r\n";
UpdateData(FALSE);
}
else
UpdateData(FALSE);
delete buffer;
return;
}
There is obviously an if statement missing there so I have no idea what you are trying to do in the missing code. There is nothing special about transferring the contents of a file between two systems. You just need to tell the receiving system how much data to expect so it waits until everything is received, and this would normally be done within a loop of continuous recv() calls, until either the total amount of data is transferred or some other indication that the transfer is complete.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Just out of curiousity, what do you think this line does?
long lenFile=recv(sock.sk,buffer,buffLength,0); Hint: it does not set lenFile to the value you sent with this sequence
long fileLen = myFile.GetLength();
send(sClient,(char*)&fileLen,sizeof(fileLen),0); If you're lucky, it returns 4 (see here[^]).
|
|
|
|
|
Hello all;
I am writing a tiny phone book program using classes.
using namespace std;
class phonebook{
public :
void add_new();
private :
char *name;
char *family;
};
void phonebook::add_new(){
phonebook *temp=new phonebook;
cin >> temp->name;
cin >> temp->family;
}
int main(int argc, char *argv[])
{
phonebook::add_new();
system("PAUSE");
return EXIT_SUCCESS;
}
Any work I do; I can't get a name and family. my program should be dynamic.
What should I do to get response?
Thanks in advance...
|
|
|
|
|
Since your code will not even compil e successfully it is little wonder it doesn't work. You are making a static call to a non-static method (phonebook::add_new(); ), which is invalid.
Try looking at your design here, every time you call add_new() you create a new phonebook object but you do not save it anywhere. Consider the contents of a real phonebook, the book contains entries and each entry contains names and numbers. So you need a collection of some sort to hold all your entries; this could be a class or one of the STL types. Perhaps you should try this without using classes as a first attempt to get the concepts right and then convert to classes later.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi all,
i m using MCIWnd function to play sound file.
when i m execute the command MCIWndPlay,its increase the threads counter but not decrese the thread counter even sound is end now.
please tell me can i find sound play by MCIWndPlay is end now or how can i close this thread.
or there is any method by which thread is automatically end when sound is finish.
please help me for this.
thanks in advance.
|
|
|
|
|
You may need to use the wait flag to wait until the operation completes. I think the test and notify are alternative options, but you need to read the documentation[^] for full details.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
How can I load put a swf in resources and how to load it?
Currently I am adding swf in resouces using "Add -> Resources", what type should I choose there?
I am using put_Movie function to load swf. It's working fine with external swf but I want to put swf in resources; this function accepts BSTR as argument which is path of swf so what I will give there. I am expecting something like
put_Movie(L"res://myswf.swf/#2/#234");
|
|
|
|
|
You would probably need to use a user defined resource type (see here[^]) to add this to your application. However you will also need to find a method that accepts the memory address of your resource to play the file. Resources are accessed directly in memory by their type and id, there is no pseudo path as you describe above.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
|
Unfortunately I could not found any method that uses swf from memory. Do you know any?
|
|
|
|
|
rahul.kulshreshtha wrote: I could not found any method that uses swf from memory. Do you know any?
Unfortunately not, you need to look at the features that are available and figure out a solution based on one of those.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi everybody:
I am greenhand in socket programming.
I want to write a little program to receive tcp data and save them from server with multi port(almost 64 ports),the data was in deferent data rate.I read msdn and decided to use CAsyncSocket.I wrote a simple class CMySocket,and overide the OnReceive function.In the function,I want to save the received data to file.
When I used the new class,I created 64 CMySocket objects,and connect to the server ports.They connected the server well,and OnReceive function was triggered.But after some seconds,for example 10 seconds or handreds seconds,some objects' OnReceive was never triggered any longer,at last all objects were still ,no data incomed.
I have no idea why my objects didnt work continuously.My class had no more function,and only overrided the OnReceive.I wondered whether there exits some method to find the problem.
The server program is written with c++ builder,and if I use c++ builder and its socket controls,I have no problem in receiving and saving data.But I dont know why it failed in VC++ 2005.
I hope your help,thanx.
modified on Sunday, December 5, 2010 11:34 PM
|
|
|
|
|
Hi Stephen,
You have not shown any code so its practically impossible to determine what is causing you grief. All I can recommend at this point is that you learn how to use the visual studio 2005 debugger[^]. It is not as difficult as it seems. My guess is that your application is generating a socket error. You should add a breakpoint in the OnReceive, OnClose and Shutdown functions and check for failures.
I would also recommend that you learn how to use a packet sniffer such as Wireshark[^].
Thanks all I can think of for now.
Good Luck,
-David Delaune
|
|
|
|
|
Thanx for your reply!I will try it.
|
|
|
|
|
Hi,I found the reason.
In OnReceive,I used a fixed length buffer to call Receive function,But in fact,sometimes the incoming data's length is great than the buffer length.So there was some data remained in system buffer,and the app didnt get them,I think it made OnReceive not be called anymore.
Thanx everybody's advice!!
|
|
|
|
|
hello guys...im trying to compile this project but getting this linker error. I have specified all the required include and library files but still it is going into wrong places and showing me the error...here is what is says
LINK : fatal error LNK1104: cannot open file '..\..\..\wrong path\src\debug\file_name.lib
what do I do? thnx
|
|
|
|
|
If that's what it says then it must be looking in that path because of your settings. Check your paths again to make sure you have not inadvertently misplaced one of them.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I have changed the following paths (VS 2008)........
- Project -> Properties -> C/C++ -> General -> Additional Include Directories(req inc files)
- Project -> Properties -> Linker -> General -> Additional Lib Directories(req lib files)
- Project -> Properties -> Input -> Additional Dependencies (req lib file)
- Tools -> Options -> Project n Sol -> VC++ Directories -> Include file (req incl file)
- Tools -> Options -> Project n Sol -> VC++ Directories -> Library file (req lib file)
now where am i missing something? is there any path still needed?
|
|
|
|
|
I think the above is correct, and just the LIB variables are important, Include directories have no bearing on the Linker. If you look at the log files from your build you should be able to see all the directories in the search order. Your original question suggested that you had a bad path in one of the strings so you also may need to check if one of them contains a variable that refers to your "wrong path".
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi there,
I have to fill CImageList with bitmaps. Each bitmap represent a flag of a country.
To do this one normally adds the bitmap files as resource, then :
CImageList allFlagsList;
CBitmap flagUSA;
flagUSA.LoadBitmap(IDFlagUSA);
allFlagsList.Add(flagUSA);
CBitmap flagFrance;
flagFrance.LoadBitmap(IDFlagFrance);
allFlagsList.Add(flagFrance);
..etc
Of course it becomes tedious to do this for all flags ( actually I already did it but want to refactor it for sake of my code!).
However I can't find a way how to load a bmp image directly into a CBitmap object.
Anyone knows ?
Thanks in advance.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
I'm not sure I understand your question, but if you are trying to load a bitmap from a file you can use LoadImage()[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|