Tigran Posted September 10, 2003 Posted September 10, 2003 Hi.. There is a problem.. I call RecieveCallback function, which is CALLBACK function for asynchronious socket's method, BeginRecieve..my kode looks like this... private static void RecieveCallback(IAsyncResult ar) { NotifyServer.StateObject so = NotifyServer.StateObject)ar.AsyncState; Socket handle = so.workSocket; IAsyncResult res = null; try{ int bytesRead = -1; bytesRead = so.workSocket.EndReceive(ar); //MessageBox.Show(bytesRead.ToString()); if(bytesRead > 0){so.sb.Append(Encoding.ASCII.GetString(so.buffer,0,bytesRead)); res = handle.BeginReceive(so.buffer,0,MAX_SIZE,0,new AsyncCallback(RecieveCallback),so); //MessageBox.Show(so.sb.Length.ToString()); }//if else MessageBox.Show(so.sb.Length.ToString()); !!!!!!!!!!!! } catch(Exception ex){ MessageBox.Show(String.Format("NotifyServer::RecieveCallback Error {0}",ex.Message)); } } The problem is , that method MessageBox hasn't ever been called,why???This seems like operation of recieving data never copletes, but it is wrong, I get all bytes which sent Quote
Administrators PlausiblyDamp Posted September 10, 2003 Administrators Posted September 10, 2003 Does it ever return 0 bytes? If not it will never execute the else portion of the code (as far as I can see) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Tigran Posted September 10, 2003 Author Posted September 10, 2003 This is an interesting thing, because in maybe any sample wrote like this, and more, when I pass this code in debug mode, I check, that after recieving last bytes the line res = handle.BeginReceive(so.buffer,0,MAX_SIZE,0,new AsyncCallback(RecieveCallback),so); doesn't call RecieveCallback method in the recursive loop, how does it understand that thet are no more bytes , if doesn't call this method ??? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.