OpenTCPStream? BMax version

BlitzMax Forums/BlitzMax Programming/OpenTCPStream? BMax version

coffeedotbean(Posted 2006) [#1]
This is some blitzPlus code to send a GET to a php script, ive been using it to send highscore data, etc. Any way ive decided to change develpment over to BMAX but im having issues with BMAX networking stuff.

In Plus i just open a TCPStream to write to, but Max seems a little more complex with sockets and streams etc.

Ive looked around the forums but cant find what im looking for. Could 1 of you pros BMAX this for me or explain a little about sockets. etc.

SendGET("/somephpscript.php?data=somedata&data2=somemoredata")

Function SendGET(Path$)
	
	Local Host$="localhost"
	www=OpenTCPStream(Host$,80)
	
	If www=0 Then
		Print "Cannot connect to Host!"
	Else
		WriteLine www,"GET "+Path$+" HTTP/1.1" 
		WriteLine www,"Host: "+Host$ 
		WriteLine www,"User-Agent: Palouza" 
		WriteLine www,"Accept: */*" 
		WriteLine www,"" 
		CloseTCPStream www
	EndIf

End Function



Yan(Posted 2006) [#2]
Local stream:TStream = OpenStream("http::domain.tld/somephpscript.php?data=somedata&data2=somemoredata")
If stream = null Then error out 

...Get ACK ETC...

stream.Close()
You may also want to take a butchers at...

http://www.blitzbasic.com/codearcs/codearcs.php?code=1474

...and...

http://www.blitzbasic.com/Community/posts.php?topic=58952#656101


[edit]
You could also do a forum search for 'BNet' and 'BNetEx' network libraries. I haven't used them myself but people have posted good things about them.
[/edit]


Booticus(Posted 2006) [#3]
And TNet too by Wave!


coffeedotbean(Posted 2006) [#4]
thanks guys ill look it over later.


Tibit(Posted 2006) [#5]
There is a very good and totally free (incl source) module for php called ETNA. It was built to do things like keeping highscores or serverlists via php and mysql. It exsists for all version of blitz too as far as I know.
Read more about it here

Side Note:
TNet is for multiplayer games and not ideal for php or ftp interaction. I'm thankful for the support Mario :)