Re: Threaded app using sockets closes



Paul G. Tobey [eMVP] napisał(a):
1. Sounds like you should forget about breakpoints entirely and just let the application crash, if it's going to do that. You can use DEBUGMSG() or OutputDebugString() to send messages indicating the thread's progress to the Output window in eVC.

2. You should still try a sleep after the last send and before the close. Send just drops the data into the socket queue. When send() returns, that does *not* mean that the data has gone out on the wire. When you closesocket(), unless you've configured the socket for immediate close, it goes through a process to try to close the socket in a clean way, so that might take some time and I'm unsure whether closesocket() waits for that before returning or not. If you immediately try to open another socket and connect it to the same port, I can believe that there might be a problem with the emulator doing that.

Paul T.


I've managed to get what I needed (run the debug on the second loop, with unfreezing my app) - Run to cursor helped a lot. Now I'm trying to reproduce my error, but a new one occured (well at least I got exceptions in two places, but can reproduce only one of them). It's in totally new place where normally the app doesn't crash but I didn't notice it's not doing what it's expected to do (the queue stuff). I'll try to correct the error, but if not I might just drop some code here again (if I run out of ideas). thanks for your help,


RadGar
.



Relevant Pages

  • Re: How do I define the Source port value when creating a socket
    ... I have the crash log from the event viewer listed below. ... I am using the WSAcalls, are they the MFC ... Or are there other socket calls in MFC. ...
    (microsoft.public.win32.programmer.networks)
  • TCP sockets -- accept() returns -1
    ... While debugging a mysterious crash in our application, the strace output ... The segmentation fault is because the program assumes a socket being ... then there is a connection pending to be ...
    (comp.os.linux.development.apps)
  • Re: How do I define the Source port value when creating a socket
    ... > Thanks so much for your advice. ... > But if I may ask, I tried to just do the Bindon the same socket I ... When you have a crash you need to record the location of it, ... another advice would be to stay away from MFC sockets wrappers and use plain ...
    (microsoft.public.win32.programmer.networks)
  • Datagram Socket Crashes when too much data to send!
    ... I have already started a topic on a problem related to Datagram Socket Speed ... If the Thread.Sleepline is commented, the application will crash almost ... an internal buffer, and stupidly crashes when this buffer is full. ...
    (microsoft.public.dotnet.framework.compactframework)

Quantcast