Results 1 to 8 of 8

Thread: socket would block on this operation

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    socket would block on this operation

    Hello All,

    Mine could be a tricky problem.
    I have developed a mail server (using free Socket Wrench component instead of winsock control). Everything works fine. I download mails and distribute. I collect mails and forward them etc. But sometimes, I get "socket would block on this operation". I am using "non-blocking connection". I have completed the development and after getting the error I noticed that in the components' tech document they suggested using "blocking connection". But now, it is not feasible for me to re-code everything. Pls suggest me something.

    Also, go thru' the following problem and see if you can give solution for anything:

    There is a password protected access database which is used to store few info. Now, here's the catch. In most of the PC (with winxp, win98, win2003) everything is working perfect, but in one winXP pc and one Win 98 pc, the application shows an error that it is not able to open the database. Would somebody tell me how I can debug this problem ? In my development PC everything works fine, and works fine at almost all other place I tested except for the two places i mentioned.

    Sometimes I also get "Illegal Operation" error. What could be the problem?

    I also keep a log file to save all the operation I do in the application. This log file could be viewed from the application. (I provided a button. If user clicks on this button, the log file would be opened in notepad. simple). One day I got an error saying that the log file is in use by another application, hence my application cannot access it. I thought that may be the user is keeping the log file open when I'm trying to write to it. So now what I do is before displaying the log file to the user, I make a copy of the original log file and display this copy to user, so that I can write to the original in the background. But I'm stilll getting this problem SOMETIMES.

    There's another issue. When I download mail I make temporary txt files and store it in a temp location. But if there's a virus in it, and if there's a anti-virus running in the application, the antivirus either locks the file or deletes it. But in the background I'm trying to access this file, and I get error. Is there any solution to this?


    Any help on these issues would be highly appreciated, as I'm struggling with these for the last six months. PLEASE.

  2. #2
    Addicted Member
    Join Date
    Mar 2006
    Posts
    178

    Re: socket would block on this operation

    Hi this is my first post and I joined up to answer your question. I'm also using SocketWrench (Secure) and have come across a similar problem.

    I wouldn't try to write the program using blocking mode, stick with non-blocking.

    The 'operation would block' error is occuring if you are trying to do an operation on the socket which would cause it to block - or hang indefinitely until something happened. You could be trying to read from the socket when there isn't anymore data there at that point. You could be trying to send data when the socket isn't ready for instance.

    If your application receives the 'operation would block' error it should be prepared to handle it and retry the operation. This is not a fatal error.
    I tend to ignore the 'operation would block' errors during reading of a socket since I handle any errors myself within the OnRead event.

    Hope this helps
    Dave

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: socket would block on this operation

    I understood what you are trying to say. What you said is a good solution. Infact, few of the place I've done this myself....but I think there one place where it's creating problem. I'm not getting this message all the time, if I keep the application running for the whole day, I get this message around two times. But neverthless, I want to solve this situation. What happens is, after everything, when I want to disconnect, I send QUIT command and I disconnect. But I suppose, the server on the net (to which I'm connecting) is sending me back some sort of reply for this command and hence the message. Or something is happening after QUIT command, but I cannot figure out what. Pls help me with this.

  4. #4
    Addicted Member
    Join Date
    Mar 2006
    Posts
    178

    Re: socket would block on this operation

    Do you have any sample code?

    Have you tried seeing if the error occurs when running under the IDE? That way you may know where the error occurs.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: socket would block on this operation

    Quote Originally Posted by davidbishton
    Do you have any sample code?

    Have you tried seeing if the error occurs when running under the IDE? That way you may know where the error occurs.

    I dont get error under IDE .

  6. #6
    Junior Member
    Join Date
    May 2005
    Location
    California
    Posts
    22

    Re: socket would block on this operation

    I answered your similar question on our forums, but thought I'd also follow up here. One thing to keep in mind is that with non-blocking sockets, "operation would block" is not a fatal error; it's advisory, telling you that the operation that you're trying to perform would cause the socket to block. For example, if you try to read data on a non-blocking socket and there's no data available, this error will be returned.

    With multiple non-blocking sockets, errors like "operation would block" and "operation in progress" are something that your application needs to be able to cope with gracefully. They're not fatal errors, and the operation that did fail with the error should be retried at a later point.
    Mike Stefanik
    sockettools.com

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: socket would block on this operation

    Quote Originally Posted by Mike Stefanik
    I answered your similar question on our forums, but thought I'd also follow up here. One thing to keep in mind is that with non-blocking sockets, "operation would block" is not a fatal error; it's advisory, telling you that the operation that you're trying to perform would cause the socket to block. For example, if you try to read data on a non-blocking socket and there's no data available, this error will be returned.

    With multiple non-blocking sockets, errors like "operation would block" and "operation in progress" are something that your application needs to be able to cope with gracefully. They're not fatal errors, and the operation that did fail with the error should be retried at a later point.
    Thank you so much for the reply (both here and at Catalyst forum).
    I did realize that "Operation would block" is not a fatal error, but how do I handle this message "gracefully", as you say . Do I need to send the command again? Like I said (in catalyst forum), in my case, I get this message after sending QUIT command.

  8. #8
    Junior Member
    Join Date
    May 2005
    Location
    California
    Posts
    22

    Re: socket would block on this operation

    What specific method are you calling that's returning the error? After you send the QUIT command, I presume you're just reading the response from the server and then calling Disconnect. If you're getting it in response to a call to the Read method, then you just wait for the Read event to fire; if you're getting it in response to a call to Write (which would be rare), you'd wait for the Write event to fire.
    Mike Stefanik
    sockettools.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width