2 Replies - 1639 Views - Last Post: 09 September 2011 - 10:57 PM Rate Topic: -----

#1 gnohs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-August 11

Winsock error 40009

Posted 06 September 2011 - 08:09 PM

'On Error GoTo l
Winsock1.Close
  Winsock1.Connect "mail.nohsfootball.com", 110

  Do Until received: DoEvents: Loop

  If sckError Then MsgBox "An error occured trying to connect to server": Exit Sub

  sendMsg "USER username"  ' Send UserName
  If sckError Then MsgBox "Error with username": Exit Sub

  sendMsg "PASS password"   ' Send Password
  If sckError Then MsgBox "Error with password": Exit Sub


' Get Number of Messages and total size in bytes
  sendMsg "STAT"
  x = InStr(Message$, " "): b = InStrRev(Message$, " ")
  messages = Val(Mid$(Message$, x + 1, b - x))
  Size = Val(Mid$(Message$, b + 1))
If messages = "0" Then
MsgBox "no new messages"
GoTo l
End If

For a = 1 To messages
      Winsock1.Tag = "RETR"
      Open "C:\Windows\Temp\eMail-" & a & ".eml" For Binary Access Write As #1
       
      sendMsg "RETR " & a
      List1.AddItem "eMail-" & a & ".eml"
  Next

  Winsock1.Tag = ""

Next
l:
Winsock.Close



It works fine when i push the button once, but when i push it again i get a 40009 error, wrong protocol or connection state....

Is This A Good Question/Topic? 0
  • +

Replies To: Winsock error 40009

#2 gnohs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-August 11

Re: Winsock error 40009

Posted 06 September 2011 - 08:32 PM

How do I make sure winsock is connected before i send a command, i think this is my problem.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Winsock error 40009

Posted 09 September 2011 - 10:57 PM

This took 2 minutes to look up in the VB6 online doc. Granted, the VB6 documentation is very hard to find these days, so I'll assume that you don't have the link. Here it is: http://msdn.microsof...2(v=VS.60).aspx . You might want to put that in your favorites. If you already know where to find this, well, look up the properties of the WinSock control, specifically the State property and all its settings.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1