EVB WINSOCK PROBLEM

Hi experts,
i want to ask about how to fix this trouble,

i have source for winsock sample like this

Private Sub Command16_Click()
                    WinSock1.RemoteHost = "smserver.com"
                    WinSock1.RemotePort = "80"
                    Winsock1.Connect
end sub

Private Sub WinSock1_Connect()
Dim strWebPage As String
Dim strCommand As String

    strWebPage = "www.smsserver.com/send.php?api_login=" & Text4.Text & "&api_password=" & Text14.Text & _
    "&action=sms_interface" & "&recipient=" & Text2.Text & "&sender=" & Text10.Text & _
    "&msg=" & Text9.Text
    strCommand = "GET " & strWebPage & " HTTP/1.0" & vbCrLf
    strCommand = strCommand & "Accept: */*" & vbCrLf
    strCommand = strCommand & "Accept: text/html" & vbCrLf
    strCommand = strCommand & vbCrLf
    WinSock1.SendData strCommand
    End If
end sub

Private Sub WinSock1_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
WinSock1.GetData sData
MsgBox sData
end sub

The problem is if i send long SMS like,
"hi, how are you? how is mom, father, sister, and others? hope everything... ok?!"
in the text9 textbox which is for all the sms text being typed, the sData response is "400 Bad Request"
but if i send SMS something like,
"hi, this is only test"
there sms send successfully!

Why is it like this? please give me solution from the source above

Thanks.
abangbataxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrianGEFF719Commented:
Hello abangbatax,

The reason you are getting this response from the server is that it does not understand your request. The data you are sending contains spaces. You need to escape the charecter sequence. However, a simple replace() should work just fine since the only problem is the space....So here is a modified connect function and an escape() function incase you want it:


Private Sub WinSock1_Connect()
Dim strWebPage As String
Dim strCommand As String

    strWebPage = "www.smsserver.com/send.php?api_login=" & Text4.Text & "&api_password=" & Text14.Text & _
    "&action=sms_interface" & "&recipient=" & Text2.Text & "&sender=" & Text10.Text & _
    "&msg=" & replace(Text9.Text," ","%20")
    strCommand = "GET " & strWebPage & " HTTP/1.0" & vbCrLf
    strCommand = strCommand & "Accept: */*" & vbCrLf
    strCommand = strCommand & "Accept: text/html" & vbCrLf
    strCommand = strCommand & vbCrLf
    WinSock1.SendData strCommand
    End If
end sub





Public Function Escape(ByVal strString As String) As String
Dim iCount As Integer
Dim retString As String

For iCount = 1 To Len(strString)
    retString = retString & "%" & IIf(Len(Hex(Asc(Mid(strString, iCount, 1)))) < 2, Hex(Asc(Mid(strString, iCount, 1))) & "0", Hex(Asc(Mid(strString, iCount, 1))))
Next iCount
Escape = retString

End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.