[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

EVB WINSOCK PROBLEM

Posted on 2006-04-21
1
Medium Priority
?
563 Views
Last Modified: 2013-11-13
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.
0
Comment
Question by:abangbatax
1 Comment
 
LVL 19

Accepted Solution

by:
BrianGEFF719 earned 225 total points
ID: 16518805
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question