Page 1 of 1
					
				I need urgent help!
				Posted: Sun Nov 12, 2006 6:22 pm
				by Inf0Byt3
				Hi guys, i need some help from you. I am making a network related app but i've got a big big problem. I manage all the events (the network ones and the window ones) in the main loop. I am using the code i posted in the Tips and Tricks section, the one to send/receive files. The problem is the callback of the send/receive procedures. If i don't use the procedures in a thread and call them normally, the window freezes. If i thread them, it works, except for the packet delivery (the received files are incomplete). What can i do to manage the events correctly? Please help!
			 
			
					
				
				Posted: Tue Nov 14, 2006 9:58 am
				by Dreglor
				could you post some code, it would help explain more about the problem right now i can't heads or tails about it
			 
			
					
				
				Posted: Tue Nov 14, 2006 1:18 pm
				by Inf0Byt3
				Well, i really cannot show you the code because it's very big (3000+) lines of code and it's all built around this event-handling stuff. It seems that the file transfer loop must be made continuous, because it send the file at once, in one piece. If i add a WindowEvent() in it, it misses packets, so the only thing i can do is to try modify the send/receive procedures. Is there any other solution for this?
			 
			
					
				
				Posted: Wed Nov 15, 2006 5:27 pm
				by Tranquil
				I know your problem. As I wrote my first network routines I had the same problem.
You need to check the Result of Send_() / SendNetworkData() and recv_() / ReceiveNetworkData().
Send_() sometimes returns a #SOCKET_Error which indicates a blocking host. That means that you have to resend your message again and again till it is completely transfered. Send_() and recv_() also returns the number of bytes transfered. Check for it. In my own Fileprotocol I splitted a file in parts of 4096 Bytes. On sending it, I added a small header to the packet which contains the packet-size so that I know the expected packetsize on the destination side. TCP/IP sometimes splits messages, so you have to call recv_() as long as your data is complete.
Its hardly to say what it's your problem without a source. But this is what you have to check for. Mostly, localhost actions works fine couse the socket is mostly not in blocking state.
Mike
			 
			
					
				
				Posted: Thu Nov 16, 2006 2:37 pm
				by Inf0Byt3
				\Yup, that's exactly what i wanted to say about this! I allmost done it, except for the fact that SendNetworkData returns -1 in the file transmission loop. That's something i've got to fix 

. BTW, is there a chance that you have some procedures for correctly sending/receiving a buffer? I can't make mine work at all 

. Ah, and i found a simple solution for my problem... Pseudocode: 
Code: Select all
{ 
  Procedure handleTransfers()
  ;Send the next packet of the file
}
{
;This is the main loop
 Call handleTransfers()
 Do the window handling stuff after handleTransfers() returns
}