Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Method of flagging a dialog control in error Pin
Still learning how to code29-Nov-10 9:47
Still learning how to code29-Nov-10 9:47 
Questionfile copy with progress. Pin
emmmatty127-Nov-10 8:30
emmmatty127-Nov-10 8:30 
AnswerRe: file copy with progress. Pin
Richard MacCutchan27-Nov-10 10:07
mveRichard MacCutchan27-Nov-10 10:07 
AnswerRe: file copy with progress. Pin
Randor 27-Nov-10 11:44
professional Randor 27-Nov-10 11:44 
GeneralRe: file copy with progress. Pin
Richard MacCutchan27-Nov-10 21:54
mveRichard MacCutchan27-Nov-10 21:54 
GeneralRe: file copy with progress. Pin
emmmatty127-Nov-10 22:41
emmmatty127-Nov-10 22:41 
QuestionLpt Capture. Pin
Ben Mess27-Nov-10 6:08
Ben Mess27-Nov-10 6:08 
QuestionSend file through socket likes yahoo Pin
darknguyen1748827-Nov-10 4:46
darknguyen1748827-Nov-10 4:46 
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  pathName first
		send(sClient,(char*)&Len,sizeof(Len),0);
		send(sClient,(char*)sendBuff,Len,0);
		//m_msgString+=m_user+":"+m_chatString+"\r\n";
		//m_chatString="";
		long nRead = 0;
		BYTE byBuffer[BUFFER_SIZE];   // Only build this once
		CString strPath = FileDialog.GetPathName();				
		CFile myFile;
		myFile.Open(strPath, CFile::modeRead | CFile::typeBinary);
		long fileLen = myFile.GetLength();
		//Send fileLen first
		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;
				
		}
			
		// Clean up
		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) // share conference
	{																			
	CFile file;
	file.Open(mess,CFile::modeWrite | CFile::typeBinary);
	long lenFile=recv(sock.sk,buffer,buffLength,0);
	long nfilerecv=0;
	while(nfilerecv < lenFile)
	{
	        //receive byte
		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 ! Sigh | :sigh:
AnswerRe: Send file through socket likes yahoo Pin
Richard MacCutchan27-Nov-10 5:25
mveRichard MacCutchan27-Nov-10 5:25 
GeneralRe: Send file through socket likes yahoo Pin
darknguyen1748828-Nov-10 4:47
darknguyen1748828-Nov-10 4:47 
GeneralRe: Send file through socket likes yahoo Pin
Richard MacCutchan28-Nov-10 6:03
mveRichard MacCutchan28-Nov-10 6:03 
AnswerRe: Send file through socket likes yahoo Pin
Chuck O'Toole28-Nov-10 7:12
Chuck O'Toole28-Nov-10 7:12 
Questionmember function don't pass to class!!!??? Pin
hasani200727-Nov-10 2:33
hasani200727-Nov-10 2:33 
AnswerRe: member function don't pass to class!!!??? Pin
Richard MacCutchan27-Nov-10 2:53
mveRichard MacCutchan27-Nov-10 2:53 
QuestionHoa can find sound play by MCIWndPlay is end now? Pin
Le@rner26-Nov-10 21:03
Le@rner26-Nov-10 21:03 
AnswerRe: Hoa can find sound play by MCIWndPlay is end now? Pin
Richard MacCutchan27-Nov-10 1:33
mveRichard MacCutchan27-Nov-10 1:33 
QuestionHow can I load put a swf in resources and how to load it Pin
rahul.kulshreshtha26-Nov-10 19:55
rahul.kulshreshtha26-Nov-10 19:55 
AnswerRe: How can I load put a swf in resources and how to load it Pin
Richard MacCutchan26-Nov-10 22:50
mveRichard MacCutchan26-Nov-10 22:50 
GeneralRe: How can I load put a swf in resources and how to load it Pin
rahul.kulshreshtha27-Nov-10 2:02
rahul.kulshreshtha27-Nov-10 2:02 
GeneralRe: How can I load put a swf in resources and how to load it Pin
rahul.kulshreshtha28-Nov-10 22:10
rahul.kulshreshtha28-Nov-10 22:10 
GeneralRe: How can I load put a swf in resources and how to load it Pin
Richard MacCutchan29-Nov-10 3:27
mveRichard MacCutchan29-Nov-10 3:27 
Question[Solved]My CAsyncSocket class doesn't receive data after some secondes. [modified] Pin
stephen_young26-Nov-10 18:16
stephen_young26-Nov-10 18:16 
GeneralRe: My CAsyncSocket class doesn't receive data after some secondes. Pin
Randor 28-Nov-10 5:57
professional Randor 28-Nov-10 5:57 
GeneralRe: My CAsyncSocket class doesn't receive data after some secondes. Pin
stephen_young28-Nov-10 17:02
stephen_young28-Nov-10 17:02 
AnswerRe: [Solved]My CAsyncSocket class doesn't receive data after some secondes. Pin
stephen_young5-Dec-10 17:39
stephen_young5-Dec-10 17:39 

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.