Aristide
Member
Code give by Erel
Hello,
I use this "same" code for the "link" to an application (Scratch) that sends bursts of "GET / POLL". I get the first "get / poll" with "keep alive" in the HTTP header for the connection. With "serversocket" object, I get an error "connection reset"
I made the same program with "socket" object, I only have one client, i get another error "read time-out"
It seem's that the event "newdata" of the stream only goes back one request.
Thank you for your help.
With serversocket
B4X:
Sub Process_Globals
Private server As ServerSocket
Private astream As AsyncStreams
End Sub
Sub AppStart (Args() As String)
server.Initialize(51042, "server")
server.Listen
StartMessageLoop
End Sub
Sub server_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("New connection")
If Successful Then
astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "astream")
End If
server.Listen
End Sub
Sub astream_NewData (Buffer() As Byte)
Log(BytesToString(Buffer, 0, Buffer.Length, "utf8"))
astream.Write("received!".GetBytes("utf8"))
End Sub
Hello,
I use this "same" code for the "link" to an application (Scratch) that sends bursts of "GET / POLL". I get the first "get / poll" with "keep alive" in the HTTP header for the connection. With "serversocket" object, I get an error "connection reset"
I made the same program with "socket" object, I only have one client, i get another error "read time-out"
It seem's that the event "newdata" of the stream only goes back one request.
Thank you for your help.
With serversocket
...
New connection
GET /poll HTTP/1.1
Referer: app:/Scratch.swf
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5, application/x-mpegURL
x-flash-version: 24,0,0,174
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; fr-FR) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/24.0
Host: 127.0.0.1:12345
Connection: Keep-Alive
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:127)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:188)
at java.lang.Thread.run(Thread.java:745)
New connection
GET /poll HTTP/1.1
Referer: app:/Scratch.swf
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5, application/x-mpegURL
x-flash-version: 24,0,0,174
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; fr-FR) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/24.0
Host: 127.0.0.1:12345
Connection: Keep-Alive
Last edited: