edit: nevermind fixed it by re-opening the sockets whenever this one specific error string is detected
this is my first time using winsock in years and am having some trouble. pretty sure all it needs is a simple line of code for closing a socket or something similar..i've just killed too many hours trying different things, so i figured i'll just ask the experts for once and hopefully nip it in the bud
i'm building off a very basic open source proxy server (it supports keep-alive and ssl), i'm making it so it bypasses sony PS3 firmware...i actually managed to get that to work though.
it's weird actually, everything works fine so it seems, in ps3 i can switch users and log in/out without a problem..but the problem occurs only when i restart my ps3, it ceases to log me in and the only way i can get it working again is if i restart the proxy server program.
here's the working log:
here's the not working log:
and here's the barebones of the code:
any help is appreciated, sorry if this thread isn't put together that well, tried to explain it as best as i could
this is my first time using winsock in years and am having some trouble. pretty sure all it needs is a simple line of code for closing a socket or something similar..i've just killed too many hours trying different things, so i figured i'll just ask the experts for once and hopefully nip it in the bud
i'm building off a very basic open source proxy server (it supports keep-alive and ssl), i'm making it so it bypasses sony PS3 firmware...i actually managed to get that to work though.
it's weird actually, everything works fine so it seems, in ps3 i can switch users and log in/out without a problem..but the problem occurs only when i restart my ps3, it ceases to log me in and the only way i can get it working again is if i restart the proxy server program.
here's the working log:
Originally posted by working
Originally posted by not working/after restarting ps3
Code:
Private curRequest(20)
Private curHost(20)
Private connType(20)
Private lenSent&(20)
Private curLength(20)
Private curResp(20)
Private sslDone(20) As Boolean
Public gstrAccessLevel As String
Public Sub cleanup(aIndex As Integer, from As String)
buck(aIndex).Close
curRequest(aIndex) = ""
curResp(Index) = ""
curHost(aIndex) = ""
sslDone(aIndex) = False
chuck(aIndex).Tag = 0
buck(aIndex).Tag = 0
lenSent(aIndex) = 0
curLength(aIndex) = ""
End Sub
Private Sub chuck_ConnectionRequest(Index As Integer, ByVal requestID As Long)
For i = 1 To 20
If chuck(i).State = sckClosing Then chuck(i).Close
If chuck(i).State = sckClosed Then
chuck(i).Accept requestID
accepted = True
Exit Sub
End If
Next
End Sub
Private Sub chuck_DataArrival(Index As Integer, ByVal bytesTotal As Long)
On Error Resume Next
Dim strdata$
chuck(Index).GetData strdata
Select Case chuck(Index).Tag
Case 1
If buck(Index).State = sckConnected Then
buck(Index).SendData strdata
ElseIf buck(Index).State = sckClosed Then
buck(Index).Connect curHost(Index)
curRequest(Index) = curRequest(Index) & strdata$
Else
If InStr(1, curRequest(Index), vbCrLf & vbCrLf) > 0 Then
chuck(Index).Tag = 0
Else
curRequest(Index) = curRequest(Index) & strdata$
End If
End If
Case 0
If Left(strdata, 8) = "CONNECT " Then
colon = InStr(1, strdata, ":")
curHost(Index) = Mid(strdata, 9, colon - 9)
SSLPORT = Mid(strdata, colon + 1, InStr(colon, strdata, " ") - colon)
begin = InStr(1, LCase(strdata), "proxy-connection: ")
If begin <> 0 Then
connType(Index) = Mid(strdata, begin + 18, InStr(begin, strdata, vbCrLf) - begin - 18)
If LCase(connType(Index)) = "keep-alive" Then curRequest(Index) = Replace(strdata, Mid(strdata, begin, InStr(begin, strdata, ":") - begin), "connection") ': MsgBox curRequest(Index)
End If
curRequest(Index) = Right(strdata, Len(strdata) - InStr(1, strdata, vbCrLf & vbCrLf) - 3)
If buck(Index).State <> sckClosed Then buck(Index).Close: DoEvents
buck(Index).Connect curHost(Index), Trim(SSLPORT)
buck(Index).Tag = 4
chuck(Index).Tag = 1
Exit Sub
End If
yea = Replace(strdata, "http://", "", , 1)
begin = InStr(1, yea, " ")
If begin <> 0 Then shit = Mid(yea, begin + 1, InStr(begin, yea, "/") - begin - 1)
If (curHost(Index) <> shit And buck(Index).State <> sckClosed) Then buck(Index).Close
curHost(Index) = shit
yea = Replace(yea, shit, "", 1, 1)
curRequest(Index) = yea
chuck(Index).Tag = 1
begin = InStr(1, LCase(yea), "proxy-connection: ")
If begin <> 0 Then
connType(Index) = Mid(yea, begin + 18, InStr(begin, yea, vbCrLf) - begin - 18)
If LCase(connType(Index)) = "keep-alive" Then curRequest(Index) = Replace(yea, Mid(yea, begin, InStr(begin, yea, ":") - begin), "connection")
End If
buck(Index).Tag = 1
lenSent(Index) = 0
If LCase(connType(Index)) = "keep-alive" Then
buck(Index).Tag = 0
If buck(Index).State = sckConnected Then
curResp(Index) = ""
buck(Index).SendData curRequest(Index)
Exit Sub
End If
End If
If buck(Index).State <> sckClosed Then buck(Index).Close: DoEvents
buck(Index).Connect curHost(Index)
End Select
strdata$ = ""
End Sub
Private Sub chuck_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
chuck(Index).Close
cleanup (Index), "chuck_error: " & Description
End Sub
Private Sub chuck_SendComplete(Index As Integer)
If curLength(Index) = lenSent(Index) Then
If connType(Index) <> "keep-alive" Then
chuck(Index).Close
Call cleanup(Index, "all data relayed")
End If
End If
If buck(Index).Tag <> 4 Then
buck(Index).Tag = 0
Else
sslDone(Index) = True
End If
If chuck(Index).Tag = 3 Then
cleanup (Index), "chuck_sendcomplete"
chuck(Index).Close
DoEvents
End If
End Sub
Private Sub buck_Close(Index As Integer)
Debug.Print "out socket close on " & Index
If buck(Index).Tag <> 0 Then
If sslDone(Index) = False Then
chuck(Index).Tag = 3
Exit Sub
End If
Else
cleanup (Index), "buck_close"
chuck(Index).Close
End If
cleanup (Index), "buck_close"
chuck(Index).Close
If buck(Index).Tag = 4 Then
If sslDone(Index) = True Then
chuck(Index).Close
cleanup Index, "buck_close ssl style"
End If
End If
End Sub
Private Sub buck_Connect(Index As Integer)
If buck(Index).Tag = "4" Then
chuck(Index).SendData "HTTP/1.1 200 Connection established" & vbCrLf _
& "Proxy-agent: PS3Update-agent/1.0.0 libhttp/1.0.0" & vbCrLf & vbCrLf
End If
If curRequest(Index) <> "" Then
buck(Index).SendData curRequest(Index)
End If
If buck(Index).Tag <> 4 Then buck(Index).Tag = 0
End Sub
Private Sub buck_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim strdatas$
buck(Index).GetData strdatas$
If Len(strdatas$) < 275 Then
workspace.Text = strdatas$
On Error Resume Next
If Left(workspace, 2) = "# " Then
Dim str As Variant
Dim fixit As String
str = Split(workspace, ";CompatibleSystemSoftwareVersion=")
fixit = Left(str(1), 6)
str(1) = Replace(str(1), fixit, "0.0000")
workspace = str(0) & ";CompatibleSystemSoftwareVersion=" & str(1)
str = Split(workspace, ";SystemSoftwareVersion=")
fixit = Left(str(1), 6)
str(1) = Replace(str(1), fixit, "0.0000")
workspace = str(0) & ";SystemSoftwareVersion=" & str(1)
str = Split(workspace, ";ImageVersion=")
fixit = Left(str(1), 8)
str(1) = Replace(str(1), fixit, "00000000")
workspace = str(0) & ";ImageVersion=" & str(1)
strdatas$ = workspace.Text
End If
End If
If curResp(Index) = "" Then
begin = InStr(1, LCase(strdatas$), "content-length:") + 15
If begin > 15 Then curLength(Index) = Trim(Mid(strdatas$, begin, InStr(begin, strdatas$, vbCrLf) - begin))
Debug.Print strdatas$
curResp(Index) = Left(strdatas$, InStr(1, strdatas$, vbCrLf & vbCrLf) - 1)
If curResp(Index) <> "" Then recvHead = True
End If
If buck(Index).Tag <> 4 Then chuck(Index).Tag = 0
If buck(Index).Tag = 0 Then buck(Index).Tag = 1
sslDone(Index) = False
If curLength(Index) = "" Then RECVDHEAD = False
If RECVDHEAD = True Then
lenSent(Index) = Len(strdatas$) - Len(curResp(Index))
Else
lenSent(Index) = lenSent(Index) + Len(strdatas$)
End If
If chuck(Index).State = sckConnected Then
chuck(Index).SendData strdatas$
DoEvents
Else
cleanup (Index), "buck_dataarrival"
Exit Sub
End If
End Sub
Private Sub buck_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
cleanup (Index), "buck_error: " & Description & " (err. no. " & Number & ")"
chuck(Index).Close
End Sub
Private Sub Form_Load()
Dim strCommandLine As String
strCommandLine = UCase(Command())
If InStr(strCommandLine, "-PORT ") > 0 Then
Dim setport As Variant
setport = Split(strCommandLine, "-PORT ")
Text2.Text = setport(1)
End If
For i = 1 To 20
Load chuck(i)
Load buck(i)
Next
chuck(0).LocalPort = Text2.Text
chuck(0).Listen
End Sub