Need Help With "Network.dll" or something else...

sitajony

Active Member
Licensed User
Hi and thanks for your answers:
I'm building a Web Server with Network.dll from Web Navigator to my server but I don't know how return a result to the navigator... I know how get the header posted from the navigator but unavailable to return a text or other...
I tried to type "bin.WriteString" with the same name Connection that bin.ReadString for get the header sended from Navigator but no effect...
Anyone can tell me how do it? Thanks!
If you want more informations tell me ;)
 

Zenerdiode

Active Member
Licensed User
Are you creating a Client object on the Server side too? On the Server, you will need to dynamically create a Client for each connection. Its hard to help further without your example code.
 

sitajony

Active Member
Licensed User
Thanks My source code:

B4X:
Sub Globals
End Sub

Sub App_Start
client.New1
serveur.New1(80)
serveur.Start
compteur.Enabled=True
   index.Show
End Sub

Sub compteur_Tick
If serveur.Pending Then
   client.Value=serveur.Accept
   bin.New1(client.GetStream,False)
   label1.Text=""
   tmp=""
   Do Until StrIndexOf(tmp,"Keep",0)>-1
            tmp=bin.ReadString
            label1.Text=label1.Text&tmp&CRLF
   Loop
'   bin.WriteString("Content-type:text/plain;"&CRLF&label1.Text)
      client.Close
End If
End Sub

Sub compteur2_Tick
End Sub
bin: Binary Object. [Binary.dll]
compteur, compteur2: Timer control set to 1000ms.
client: Client object [Network.dll]
serveur: Server object [Network.dll]

I've noticed that when I get the data send by the Navigator, it stop and no response anymore from the server, must close it everytime... Where's the error?
 
Last edited:

sitajony

Active Member
Licensed User
It's ok now it doesn't freeze any more, but unavailable to return a string on the navigator... bin.WriteString it's not the better way? Maybe should I make a new connection with bin.New1()?

Edit: It freeze again :( How get all data with bin.ReadString?
 
Last edited:

sitajony

Active Member
Licensed User
Maybe it's not the Network.dll that I've to use?
When I type the host name on the Navigator adress bar it return only web the web server have terminated the processus "The web page can't be load"...
Anyone can Help me?
 

Zenerdiode

Active Member
Licensed User
You shouldn't have (what could turn out to be) an endless loop in the Timer's Tick event. Its all very hap-hazard. :confused:

If there is enough data pending for the reading loop; there is a potential for the Timer Tick sub to be re-entered. If that doesn't happen, the next time the timer ticks it will test for a pending client (If serveur.pending Then...) but there won't be a client pending as it has already been accepted (and closed) in the previous execution of the tick sub.

Please read the help for Network.dll and have a look at the simplified example code. This will give you direction of the server accepting one client.
 

agraham

Expert
Licensed User
Longtime User

sitajony

Active Member
Licensed User
If you are concerned that the timer-tick action may alter some data that is being alerady operated upon, so producing an inconsistent result, I suggest that you protect it explicitly. Presumably (!) it is not difficult to set a global boolean at the start of the button operation, and cancel it at the finish. Then if a tick event finds the boolean set either the event is ignored (if another tick will subsequently substitute) or some separate flag is set to indicate a postponement.

Typically it was useful, if going to the operating system to fetch data, to be able to accept interrupts such as timers in the interim. This makes it possible to arrange a timeout so that a slow fetch does not hang the program.

Mike.

On the navigator a client is not everytime connected so I beleive that it was the best way... So I lets the Pending and do an other timer for data?

But there's the same problem: Unable to show a message on the navigator...
 
Top