Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Create a great and really fast Web Server with Basic4PPC!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2010, 01:20 PM
sitajony's Avatar
Basic4ppc Veteran
 
Join Date: Mar 2010
Location: France
Posts: 416
Awards Showcase
Beta Tester 
Total Awards: 1
Default Create a great and really fast Web Server with Basic4PPC!

Hi, since few months I didn't know how create a web server on our PPC, I beleive that we've to use a lot of Library with a lot of Mb lol...
In fact it's easy to create our own web server with Basic4PPC...
You just need Network.dll and Binary.dll...

For beginig, you need to create a Server on PORT "80":
Server.New1(80)

Then you must to declare the Client class:
Client.New1

Now you can start you server but it's not finish
Server.Start

You need to create a Timer like the Network.dll example and set interval to 500ms or other and enable it...
wait.Interval=500
wait.Enabled=True

In the "wait" Tick sub you wait for request from a web navigator:
If Server.Pending Then 'Client coming in!

In this condition you accept his request from the navigator:
Client.Value=Server.Accept

Now with the Binary.dll you open the datas sended by the navigator, this datas contains the URL, Method (GET/POST), Variable set in POST Method and some usefull datas...:
bin.New2(Client.GetStream,1252)

Once that you've open the data you've to read this data as string... The datas sended by the navigator is in Byte[] format, you need to convert it in String format:
Dim buffer(4096) As byte
bin.ReadBytes(buffer(),
4096)
datas=bin.BytesToString(buffer(),
0,2048)


Now the "datas" variable contains the informations needed... This is an receive data example:

Code:
GET / HTTP/1.1
Accept: image/
jpeg, application/x-ms-application, image/
if, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, applicatio
/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: fr-FR
User-Agent: Moz
lla/
4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729
 .NET CLR 
3.0.30729; Media Center PC 6.0; Tablet PC 2.0; In
oPath
.2; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Host: 
127.0.0.1
Connection: Keep-Alive
In first line we can see the Method and the url asked by the navigator...
For split this values you just need to use the SubString() function and StrSplit():
Sub Globals
'Declare the global variables here.
Dim buffer(4096) As byte
Dim arg(3) AsString
End Sub
Sub getinfo(txt)
arg()=
StrSplit(SubString(txt,0,StrIndexOf(txt,CRLF,0))," ")
End Sub
With this function you get the Method name, URL asked and the protocol (Don't care with it)

Sorry I've to go... Will be finish in few hours...
Edit: Sorry I've not enough time in this moment... So be patient for see the end

Last edited by sitajony : 05-31-2010 at 10:13 PM.
Reply With Quote
  #2 (permalink)  
Old 06-01-2010, 10:38 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 295
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Looks very interesting
keep up the good work :-)
Reply With Quote
  #3 (permalink)  
Old 06-01-2010, 06:42 PM
sitajony's Avatar
Basic4ppc Veteran
 
Join Date: Mar 2010
Location: France
Posts: 416
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks , yes I'll continue in few days, for now I've no times...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a Basic4ppc library Erel Code Samples & Tips 126 05-19-2011 05:27 PM
VB6 Server BASIC4PPC Client Problem snakex Questions (Windows Mobile) 2 02-24-2010 11:19 PM
Great DB With Table Full size windows APP scott93727 Share Your Creations 6 08-26-2009 04:48 AM
Can I use basic4ppc to create a Bluetooth middleware solution? Olav Questions (Windows Mobile) 1 09-22-2008 11:21 AM
Firefox is a great browser Erel Chit Chat 4 05-19-2007 09:41 AM


All times are GMT. The time now is 10:46 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0