Re: Suggestions to resolve Runtime Error 75 path/file access denied
Thanks Dee-u and Doogle! I was thinking the Load statement would auto increment upon execution. Plus, I had some Close statements in the project which wern't working.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Hi Dee-u,
Yes, I figured that using the Unload method would also close the socket when winsock unloaded.
I do have the Close code setup in the SendComplete event.
In addition to the above concern, Im also facing the challenge of properly Unloading Winsock. What happens is the the Unload method is invoked but the next time the Load method is invoked, error 360 appears (object already loaded). If I add the Doevents statement for testing purposes, it works fine for 10 minutes or so but then the error occurs again.
The above only happens on win xp with sp3 and doesn't happen on Vista Home Premium.
Im not sure if this is important but Im not resetting the integer of 1 back to 0 and then to 1 again. Im just letting 1 be re-used the next time winsock is loaded.
Please see the latest attachment for where Im at. Any additional help from yourself or anyone else would be great.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
I cannot follow what your program is doing but it looks like you are just loading one instance of a winsock, is that right? What is your purpose with that? The index is never increased so why not just use the original one?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
dee-u: The idea came from a suggestion of mine in an earlier post. There is a 'funny' problem which manifests itself after the application has been running fine for days at a time. At one point the application was failing due to a reported Winsock buffer shortage and it migrated to the Runtime Error 75 at a later date following some changes to the code. My suspicion is that the root problem is still with Winsock.
The idea of using a dynamic Winsock instance was to ensure that all the Winsock resources were released after each process (a 'process' is triggered through a circa 2 minute timer) by unloading the control.
techsent: I think you will have to be careful where and when you unload the control. I suspect that trying to unload it within a Winsock event (eg Close) will not always have the desired effect.
Whilst it may seem counter intuitive I think you should close the Socket at the end of a 'process' and unload it when the Timer triggers to start the next 'process'. The Close method is asynchronous and will take a finite time to complete whilst your program is still running. You could get to a situation where you are attempting to unload the control whilst it is stil closing.
The 2 minute time delay between issuing the Close and the Unload will be long enough to ensure that the Socket has closed in a graceful manner. As a 'backstop' you could even check that it is closed before attempting to Unload it.
Something like this at the start of the Timer event
Code:
Dim intF as Integer
If Winsock(1).State <> sckClosed Then
Winsock(1).Close
Do Until Winsock(1).State = sckClosed
intF = DoEvents
Loop
End If
Unload Winsock(1)
(I know I banged on about DoEvents earlier but I think its use here is safe and valid since the Timer is the only asynchronous event running and the DoEvents will not cause the Timer or anything else to be triggered again.)
The above will check the socket is closed and if it isn't will close it. Note that if the Socket isn't closed the Winsock(1).Close event will trigger so you should make sure that there's nothing in that event related to the Socket itself.
Later on in the Timer event, before you set the Winsock properties
Code:
Load Winsock(1)
If you follow this approach you'll also have to add a Load Winsock(1) in the Form_Load event so there's one to be unloaded on the first triggering of the Timer.
(Obviously I've used 'Winsock(1)' purely as an example)
I'm still of the opinion that the Process Control can be simplified and all this problem circumvention is not really required - I think I'll have a go, if no one minds, once I've indented your code to make it a little more readable (for me at least)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Originally Posted by dee-u
Here, I reformatted the last version for anyone who is interested to fiddle with it.
Hey dee, it seems like you are trying to help, but before confusing people in the post it would probably be a good idea to read through the whole post instead of making assumptions. The case is that the file descriptor is just not being cleared up correctly, after days of the program running stable on two computers (both are very short on RAM, and the one that gives the error most frequently is lowest on RAM out of the two). The only thing I can think of is the socket receiving the data from the other end, but leaving small bits of trash in the buffer.. which builds up, this is what Doogle has explained already.
Furthermore, you should not take the source and touch it up for redistribution in the thread yourself. Techsent should be the only one submitting sources of his program, and receiving his help or revisions privately. This man has worked very hard on SP for a long time. I am not him, and I certainly don't have the authority to judge, but when it comes to this please, remember that making 3-4 posts of quick responses isn't going to do anything, especially when you overlook most of the thread.
But, thanks for your efforts anyways.
PS - Doogle and the admin/moderator helping, thank you for it as well.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Originally Posted by kevr
Hey dee, it seems like you are trying to help, but before confusing people in the post it would probably be a good idea to read through the whole post instead of making assumptions. The case is that the file descriptor is just not being cleared up correctly, after days of the program running stable on two computers (both are very short on RAM, and the one that gives the error most frequently is lowest on RAM out of the two). The only thing I can think of is the socket receiving the data from the other end, but leaving small bits of trash in the buffer.. which builds up, this is what Doogle has explained already.
Furthermore, you should not take the source and touch it up for redistribution in the thread yourself. Techsent should be the only one submitting sources of his program, and receiving his help or revisions privately. This man has worked very hard on SP for a long time. I am not him, and I certainly don't have the authority to judge, but when it comes to this please, remember that making 3-4 posts of quick responses isn't going to do anything, especially when you overlook most of the thread.
But, thanks for your efforts anyways.
PS - Doogle and the admin/moderator helping, thank you for it as well.
I am lazy to read through all the posts but tried to see what is in the latest version and is offering some constructive criticism, sorry about that if that confuses others. =) I merely automatically indented the code for easier reading for other members who would want to take a look, Doogle himself wants it indented before looking so I did it.
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
In the DataArrival event and in the other places you are trying to read a file or delete a file you should check first if it is existing like:
Code:
If Len(Dir$(sErrorLogPath)) > 0 Then
Open sErrorLogPath For Input As #hFile
Do While Not EOF(hFile)
Line Input #hFile, xx
List2.AddItem xx
Loop
Close #hFile
End If
Another thing, I am not sure if this happens on the other email providers but when I am testing it with gmx it is deleting the messages in my Inbox, is this by design or perhaps I am just missing some setting in gmx?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Hey Dee-u,
Great approach on the file check code. I'll add it into the next update.
Awhile back I was also using gmx for testing. This code should only delete emails if the subject line contains the keyword. In the latest update above, I used syspit as an example keyword.
I'll sign up for a new gmx email account and check into your discovery.
I just started the latest attachment on xp.
thanks,
Techsent
Last edited by techsent; Aug 18th, 2010 at 05:39 AM.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
I sent a test message from my gmail to gmx using Test as the subject and the message itself and it was deleted everytime I run your code, winsock was reporting about this logging in failure but when I put breakpoints in the code it was hitting them. Did you use port 110 also?
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Hey Dee-u,
I duplicated your efforts but the Test email remained in the inbox. What's interesting though is that the Test email subject line doesn't display in the pop3 connect listbox upon email retrieval. The other emails subject lines do.
Yes, I was also experiencing the failed login issue as well. It occured immediately after signing up for an account but the next day I was able to login ok. Yes, I use port 110.
Before I release this program to the public, I'll contact the gmx admin to discuss your findings as the problem doesn't occur with aol or my domain email server. Also, the problem may be with the parsemsg sub code as well.
Status update on the running test = 2 days and 4.5 hours with no errors! I'll status again in a couple more days.
Doogle, once again, thank you for helping me. I don't want to jump the gun, but I feel that your code is a logical implementation along with everyone else's suggested fixes.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Yeah, I spoke too soon
at 6 days 9 hours earlier today the 10055 out of buffer space error appeared again.
Doogle, I started thinking about your comments in an earlier post where the internal buffers could be the problem.
I ran some searches on the net and came up with this statement from Microsoft:
"This behavior can occur because computers that run Microsoft Windows NT clients and use excessive numbers of ports (more than 3,976 simultaneously) may run out of ports before TCP/IP releases closed connections. The TCP/IP-state computer dictates that when a connection is closed, the connection is not released until two maximum segment lives (MSLs) have passed. This state is defined as the Time-wait state. Since one MSL is defined as 120 seconds, it takes four minutes for a closed connection to be released in TCP/IP. "
Since it takes 4 min to actually close the connection and the pop3 connect fires every 2 min, the buffers may be getting filled up and not released in time for the next connect.
Another option may be to code pop3 connect to only connect once every 5 min (which I can certainly live with if it resolves this issue). This would then give enough time for windows to naturally close its connection thus clearing the Time_Wait state.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
I was aware of the issue with re-using Ports but have only come upon problems when the LocalPort is not set to Zero, I believe you're setting it to zero before opening the connection. When it's set to zero, TCP allocates a free port number to use. What I'm not clear on is whether the internal Buffers are destroyed before or after the Time-Wait, if the former then you could have some lying around.
I'm pretty sure it's a timing issue of some sort, if you opted to a 5 minute delay I suggest you start the 5 minute timer after you've processed all the data rather than let the timer run whilst the data is being processed - just in case it takes a minute or two to actually perform the pocess (eg big e-mail)
Re: Suggestions to resolve Runtime Error 75 path/file access denied
Thanks Doogle.
I know you alluded to the timing issue before. I should have invoked it back then. I have it set now. Also, the pop3 connect will now fire at 5 min intervals.
Attached is the latest update and fully usable project. Please go through the Readme.txt file to get it up and running.
I'll get the test started once I get home in a couple of hours.
Re: Suggestions to resolve Runtime Error 75 path/file access denied
late last night after the 6 day mark, the "10055 no buffer space is available" error appeared at Winsock1(1).Connect tstring, kevo.
please note, I did add the DoEvents statement below the Unload Winsock1(1) entry because I wanted to make sure winsock unloaded before it loaded up again.
I'll be back in a bit, as I need to run some errands with my kid.
Code:
Private Sub Timer3_Timer()
Static intCount As Integer
intCount = intCount + 1
If intCount = 4 Then
intquitwinsck = 0
SaveSettingString HKEY_CURRENT_USER, "Software\System Pitstop", _
"pop3prse", _
"1"
Static tstring As String
Static ustring As String
Static xstring As String
Static kevo As String
tstring = ReadINI("POP3", "Incoming_Server", App.Path & "\config\pop3.ini")
ustring = ReadINI("POP3", "Port", App.Path & "\config\pop3.ini")
username = ReadINI("POP3", "Username", App.Path & "\config\pop3.ini")
password = ReadINI("POP3", "Password", App.Path & "\config\pop3.ini")
xstring = ReadINI("POP3", "Keyword", App.Path & "\config\pop3.ini")
kevo = Val(ustring)
vvd1 = getstring(HKEY_CURRENT_USER, "software\System Pitstop", _
"Pop3testStart")
If vvd1 = "1" Then
Else
qss1 = getstring(HKEY_CURRENT_USER, "software\System Pitstop", _
"mnudisplaytips")
If qss1 = "True" Then
Else
SaveSettingString HKEY_CURRENT_USER, "software\System Pitstop", _
"modemsg", _
"0"
SaveSettingString HKEY_CURRENT_USER, "Software\System Pitstop", _
"modemessages", _
"Querying the remote POP3 email account for a remote start keyword"
SaveSettingString HKEY_CURRENT_USER, "software\System Pitstop", _
"modemsg", _
"1"
SaveSettingString HKEY_CURRENT_USER, "software\System Pitstop", _
"modemsgToff", _
"1"
End If
End If
Dim intF As Integer
If Winsock1(1).State <> sckClosed Then
Winsock1(1).Close
Do Until Winsock1(1).State = sckClosed
intF = DoEvents
Loop
End If
Unload Winsock1(1)
DoEvents
Load Winsock1(1)
m_State = POP3_Connect
Winsock1(1).Close
Winsock1(1).LocalPort = 0
Winsock1(1).Connect tstring, kevo
intCount = 0
Timer3.Enabled = False
End If
End Sub
"Specifies that one or more declared local variables are to remain in existence and retain their latest values after termination of the procedure in which they are declared."
However, since we're now unloading/re-loading winsock, Im not sure if the above applies. But, I made the changes below and everything is continuing to work.
The way it was...
Code:
Private Sub Winsock1_DataArrival(index As Integer, ByVal bytesTotal As Long)
Static AmtMessages As Integer 'the number of messages to be loaded
Static strData1 As String 'the data of the loading message
Static strBuffer As String 'the buffer of the loading message
End Sub
Now, I changed strData1 from Static to Dim and then moved AmtMessages and strBuffer to the General Declarations section and then declared them as Public instead of Static.
Sorry for the delayed response. I didn't see the email for your last post above.
As of last sunday, the problem remains. The Out of buffer space error continues.
Today, I ended implementing westconn1's idea from one of his earlier posts. Thanks Pete!
I have my main program and when it is started it then auto starts the pop3 module that we have been working on in this thread.
In the main program, I've now coded it to auto shutdown and then auto start the pop3 module every 3 days. This should avoid the problem.
Here's my code from the main program.
'Bas module for the TerminateTask function
Code:
Option Explicit
Declare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
Private Target As String
Public Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long
Dim buf As String * 256
Dim Title As String
Dim length As Long
' Get the window's title.
length = GetWindowText(app_hWnd, buf, Len(buf))
Title = Left$(buf, length)
' See if this is the target window.
If InStr(Title, Target) <> 0 Then
' Kill the window.
SendMessage app_hWnd, WM_CLOSE, 0, 0
End If
' Continue searching.
EnumCallback = 1
End Function
' Ask Windows for the list of tasks.
Public Sub TerminateTask(app_name As String)
Target = app_name
EnumWindows AddressOf EnumCallback, 0
End Sub
'set ggv as a public string variable
'set Date3 as the current Date/Time
Code:
(General) (Declarations)
Public ggv As String
Dim Date3 As Date
'when the main program starts, the current date/time is loaded into the ggv public string variable.
Code:
Private Sub Form_Load()
ggv = Now
End Sub
'the main program then uses timer1 which is set to a 1 second interval.
Code:
Private Sub Timer1_Timer()
'the Date3 gets the current date/time every second
Date3 = Now
'this code sets the kk string variable and then uses the DateDiff function to load the difference
'in days between the ggv variable which is the original date/time when the main program
'started and the Date3 value which is always the current date/time. Once the kk string
'reaches 3 days, the kk variable is cleared and the ggv variable uses the new current date/time
'via the Now function. Timer 2 is then 'enabled which then shuts down the pop3 module.
Dim kk As String
kk = DateDiff("d", ggv, Date3)
If kk = "3" Then
kk = ""
ggv = Now
Timer2.Enabled = True
End If
End Sub
'turns off timer 2 after an initial 3 second interval.
'turns on timer 3 after an initial 4 second interval.
'shuts down the pop3 module.
Code:
Private Sub Timer2_Timer()
Timer2.Enabled = False
Timer3.Enabled = True
TerminateTask "SysPitPOP3A"
End Sub
'turns off timer 3 after an initial 4 second interval.
'Starts the pop3 module back up again to run for another 3 days.
Code:
Private Sub Timer3_Timer()
Timer3.Enabled = False
Call ShellExecute(0&, vbNullString, App.Path & "\" & "Sys_Pitstop_popspm.exe", vbNullString, _
vbNullString, vbNormalFocus)
End Sub
Thank you very much for all of your help and time. Marty and everyone else, I also appreciate your knowledge and help as the pop3 module code has definitely been optimized via your suggestions and input.
I have a few more months to go before this program becomes live. Once it is, I'll give all of you a free registration code and postal mail a cd for those that would like one.
Thanks again,
Patrick
Last edited by techsent; Oct 13th, 2010 at 10:01 PM.