开发者

Winsock error 40009 vb6

 Winsock1.Connect "mail.website.com", 110

 Do Until received: DoEvents: Loop

 If sckEr开发者_运维技巧ror 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

When i run this the first time it works perfectly, but when i try to run it a second time w/o closing the app, it gives me the 40009 error. I'm thinking im trying to send data before its connected. is there a way to see if winsock is connected? somthing like

if winsock1.state = true then...


You didn't list all of the code, but I'm guessing that the variable received is not reset, causing you to fall through directly to the sendMsg "USER username" code early. You have to let the cinnection actually happen/complete before you can start writing to the socket.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜