From: B on 10 Jan 2010 16:43 On 2010-01-10 17:21:19 +0000, eric(a)boese-wolf.eu (Eric B�se-Wolf) said: > I would like to get a copy of your code. > > My e-mail adress is valid. > > Eric Right, well its not entirely fixed yet. Thought it was but it isn't. If anyone can fix it / offer me some insight, that would be great. The latest code can be found here: http://pastebin.com/m601b2426 I have a feeling its down to the way I'm using threads. Basically, when a file is sent or received, the process launches in its own thread: void *MyFrame::send_fileT(void* tid) { accessHelper* ah = static_cast<accessHelper*>(tid); MyFrame* This = ah->This; bool enc= This->encButtonOn->GetValue(); send_file(fileSendID,enc, This); pthread_exit(NULL); } void *MyFrame::receive_fileT(void* tid) { accessHelper* ah = static_cast<accessHelper*>(tid); MyFrame* This = ah->This; bool enc= This->encButtonOn->GetValue(); receive_file(enc, This); pthread_exit(NULL); } And then the encryption / decryption routines are called from within the functions send_file and receive_file. Perhaps there is some strange pthread synchronisation issue going on which I don't know about. B.
From: Barry Margolin on 10 Jan 2010 22:01 In article <018eb1c7$1$15160$c3e8da3(a)news.astraweb.com>, B <B(a)home> wrote: > On 2010-01-10 17:21:19 +0000, eric(a)boese-wolf.eu (Eric B�se-Wolf) said: > > > I would like to get a copy of your code. > > > > My e-mail adress is valid. > > > > Eric > > > Right, well its not entirely fixed yet. Thought it was but it isn't. If > anyone can fix it / offer me some insight, that would be great. The > latest code can be found here: > > http://pastebin.com/m601b2426 > > I have a feeling its down to the way I'm using threads. Basically, when > a file is sent or received, the process launches in its own thread: > > void > *MyFrame::send_fileT(void* tid) > { > accessHelper* ah = static_cast<accessHelper*>(tid); > MyFrame* This = ah->This; > bool enc= This->encButtonOn->GetValue(); > send_file(fileSendID,enc, This); > pthread_exit(NULL); > } > > void > *MyFrame::receive_fileT(void* tid) > { > accessHelper* ah = static_cast<accessHelper*>(tid); > MyFrame* This = ah->This; > bool enc= This->encButtonOn->GetValue(); > receive_file(enc, This); > pthread_exit(NULL); > } > > And then the encryption / decryption routines are called from within > the functions send_file and receive_file. Perhaps there is some strange > pthread synchronisation issue going on which I don't know about. I haven't looked at the code (it's way too much), but are you continuing to use the socket in the main thread while this thread transfers the file through the same socket? That won't work, because when the main thread reads from the socket it might be data that was intended for the receive_file thread. -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
From: B on 11 Jan 2010 07:18 On 2010-01-11 03:01:48 +0000, Barry Margolin <barmar(a)alum.mit.edu> said: > In article <018eb1c7$1$15160$c3e8da3(a)news.astraweb.com>, B <B(a)home> > wrote: > >> On 2010-01-10 17:21:19 +0000, eric(a)boese-wolf.eu (Eric B�se-Wolf) said: >> >>> I would like to get a copy of your code. >>> >>> My e-mail adress is valid. >>> >>> Eric >> >> >> Right, well its not entirely fixed yet. Thought it was but it isn't. If >> anyone can fix it / offer me some insight, that would be great. The >> latest code can be found here: >> >> http://pastebin.com/m601b2426 >> >> I have a feeling its down to the way I'm using threads. Basically, when >> a file is sent or received, the process launches in its own thread: >> >> void >> *MyFrame::send_fileT(void* tid) >> { >> accessHelper* ah = static_cast<accessHelper*>(tid); >> MyFrame* This = ah->This; >> bool enc= This->encButtonOn->GetValue(); >> send_file(fileSendID,enc, This); >> pthread_exit(NULL); >> } >> >> void >> *MyFrame::receive_fileT(void* tid) >> { >> accessHelper* ah = static_cast<accessHelper*>(tid); >> MyFrame* This = ah->This; >> bool enc= This->encButtonOn->GetValue(); >> receive_file(enc, This); >> pthread_exit(NULL); >> } >> >> And then the encryption / decryption routines are called from within >> the functions send_file and receive_file. Perhaps there is some strange >> pthread synchronisation issue going on which I don't know about. > > I haven't looked at the code (it's way too much), but are you continuing > to use the socket in the main thread while this thread transfers the > file through the same socket? That won't work, because when the main > thread reads from the socket it might be data that was intended for the > receive_file thread. Hi barry, thanks for you suggestion. In answer, absolutely not. I have 3 sockets set up: one which is only used for chat, one used to say that a file is about to be transferred, and one for actually transferring the file. There is no interference between sockets. Besides which everything works as it should when the encryption setting is turned off. To reiterate, the problem is that encryption functionality only fully works when both client and server are on the same machine (i.e. localhost). Time permitting, I will paste the relevant bits of code a little later. Thanks, B.
From: Rainer Weikusat on 11 Jan 2010 08:30 B <B(a)home> writes: > On 2010-01-11 03:01:48 +0000, Barry Margolin <barmar(a)alum.mit.edu> said: >> In article <018eb1c7$1$15160$c3e8da3(a)news.astraweb.com>, B <B(a)home> >> wrote: [...] > To reiterate, the problem is that encryption functionality only fully > works when both client and server are on the same machine > (i.e. localhost). To reiterate the solution: n=read(fd, buffer, 2048); if(enc)encryptHelper(buffer,n); n=send(sockFile_, buffer, n, 0 ); [called in a loop] THIS CODE IS BROKEN. There is no guarantee that the 'n' returned by send will have the same value the 'n' passed to it had and when (not if) this happens, only a part of the content of 'buffer' is actually transferred.
From: B on 11 Jan 2010 11:15
On 2010-01-11 13:30:56 +0000, Rainer Weikusat <rweikusat(a)mssgmbh.com> said: > B <B(a)home> writes: >> On 2010-01-11 03:01:48 +0000, Barry Margolin <barmar(a)alum.mit.edu> said: >>> In article <018eb1c7$1$15160$c3e8da3(a)news.astraweb.com>, B <B(a)home> >>> wrote: > > [...] > >> To reiterate, the problem is that encryption functionality only fully >> works when both client and server are on the same machine >> (i.e. localhost). > > To reiterate the solution: > > > n=read(fd, buffer, 2048); > if(enc)encryptHelper(buffer,n); > n=send(sockFile_, buffer, n, 0 ); > [called in a loop] > > THIS CODE IS BROKEN. There is no guarantee that the 'n' returned by > send will have the same value the 'n' passed to it had and when > (not if) this happens, only a part of the content of 'buffer' is > actually transferred. Ah I see, thankyou kindly. Will look into fixing right away :-) B. |