| | I am currently making a game. And I want to use a command through php to ineract with a visual basic app on my server. Is it possible? and how? |
|
|
I've been programming in VB for ten years, can you describe what you are trying to do with a little more detail? I think it is possible to do. PM me or post back and I'll help you out.
I was pretty sure that only ASP can interact with Visual Basic which would mean no unless you have a Windows Server for your hosting that supports ASP. I don't know really though I'm still relatively new to Visual Basic. Last I knew though it was only ASP.
1. The PHP program writes some data to a file in some format. 2. The VB program constantly sees if a file is there for it to read. 3. The VB program processes it and puts the result back in another file. 4. The VB program deletes the original file. (so that the PHP program can create a new one later) 5. The PHP program opens the file the VB program wrote, and has the results. 6. The PHP program deletes the file. Another way I could see this working is using a Winsock control in the VB program, and then using the socket functions of PHP to connect to it and process the request. This technique seems more practical now that I think about it. Here is how I would write this one. 1. The VB program is constantly listening for connections. 2. The PHP program connects to the IP address 127.0.0.1 (your computers IP) or localhost 3. The PHP program sends what needs to be done to the VB one. 4. The VB program returns the data and closes the connection. The technique I wrote above seems more practical because it can handle multiple requests, instead of just one file. It probably is slightly faster (by a very small amount) because the computer doesn't need to write to the hard disk constantly. The opposite, using VB and calling a PHP program can be done. I am currently writing a game that will use this technique for match making. It works like this. 1. You have a PHP program that does a certain function and accepts its data through GET CODE <?PHP $variable = $_GET['mode']; // if you have the url, http://www.whateversite.com/phpprogram.php?mode=1, the $variable = 1. PHP?> 2. The VB program uses the Inet control, and sends the request. 3. The PHP program would output its result using the print() or echo() variable. I hope this helps you guys out a lot. I'll be happy to guide you along and answer any other questions you have.
You might find this question strange, but well, i'm a noob.. So it is possible to write programs in C, VB, put them on server and make them "work" and intereact to PHP ?!
Any good tutorials on that, or any good simple free programs that do the same? (open source possibly...)
I also thought ASP was the only language that could interact with VB. I may be mistaken though.
Have a great day! -Tom.
ASP is written in a language that has BASIC as it's foundation...
Traditionaly, Microsoft IIS web server, was used to host ASP pages, and Apache was used to host PHP pages... There is a plugin (or module) for IIS and PWS that allows processing of PHP, but it's not that good, and it is very limiting in power, i believe PHP works only in CGI mode... Anyways, not to stray from the topic... There are few ways to connect VB with PHP scripts... Least efficient is through file, as ghostrider said... It's inefficient, since it consumes much CPU time, and thus we'll forget about it (I tried similar approach once, for connecting VB program, with QB program... Not good) Second method is by using MySQL for exchange of information... Connect VB to MySQL server, connect PHP script to MySQL server, and voila... Easy setup of information... This could be a good method, I'm using it for displaying some info on my site... May be non-efficient though, if too frequent queries should occur... Third method, again mentioned by ghostrider, involves using socket functions of PHP, to connect it directly to your VB application... A good method, probably the best option... The second part of it, transmitting data to PHP script, I would use POST method, not GET... First, GET metod has a limitation to its length (2K I believe), and POST is used to transfer large quantities of data... Here, I'm including code used to send data via POST methid, using Microsoft Internet Controls OCX... Just add it to your project, and use the following code: CODE Public Sub SendData(ByRef wb As WebBrowser, ByVal Params As String) Dim vPost As Variant Dim vFlags As Variant Dim vTarget As Variant Dim vHeaders As Variant Dim aByte() As Byte Dim i As Long ' Params are in the following format <param-name>=<param-value>[&<param-name>=<param-value>[&...]] PackBytes aByte(), Params vPost = aByte vFlags = &H2 Or &H4 Or &H8 Or &H10 vHeaders = "(anti-spam-(anti-spam-content-type:)) application/x-www-form-urlencoded" & vbCrLf wb.Navigate "http://your-server/php-script.php", vFlags, vTarget, vPost, vHeaders End Sub Private Sub PackBytes(ByRef ByteArray() As Byte, ByVal PostData As String) Dim i As Long Dim j As Long Dim c As String j = Len(PostData) - 1 If j < 0 Then Exit Sub End If ReDim ByteArray(j) For i = 0 To j c = Mid(PostData, i + 1, 1) If c = Space(1) Then c = "+" End If ByteArray(i) = Asc(c) Next End Sub This code is sure to send data to your script, via POST methid. You can ofcourse parse resulting webpage, and control your VB application taht way too... If you want, I can send you a DLL that you can use to connect with MySQL server, and read and write do MySQL databases, just PM me... Hope this helped a bit... Oh yeah, just remembered... Since Apache works (mostly, and preferably) on Linux, and VB applications can't do that (sadly Cheers QUOTE(Galahad) Oh yeah, just remembered... Since Apache works (mostly, and preferably) on Linux, and VB applications can't do that i'm kinda noob programmer, but i found this post very interesting. i didn't remember that VB aps can be run only in windows environment so i posted this question. i won't learn Vb but C and C++ since it can be compiled both for linux and windows environments. My logic suggests me that C programs could be written to interact with php, and it's kinda logical couse php is written in C (i guess). So if at any time of my life i want to make an application in C to interact with PHP what would be the right way to do that!? It is so soon to talk about that for me, but you don't need to answer right now, and maybe there is more ppl interested in this subject so you could writte anyway. What is the difference between running PHP as Module or as CGI script, how is all of that conected with basic root program of PHP (what is root program of PHP, how can i start modifiying php, and is it smart to do that, just for fun, and for learning purposes) thanks
Dear it01y2 You can transfer Data between VisualBasic and PHP via URL Like this :
CODE $Somename = $_GET['someurl name']; or CODE $Somename = $_POST['someurl name']; But its better make code with GET Method In visualBasic You can generate one HTML page and form and make it for send data form game to server i read Galahad's post You can use it him code for vb
Similar Topics
Keywords : php, interact, visual, basic, app, server
PHP pages permission on Apache Server (1) Hello, I want to know what permissions for PHP pages should be given on Apache web server so that upload to server via ftp from your mobile phone :-) (8) wappyFTP v1.00 by wappy --- site: http://cult.trap17.com mail: admin@cult.trap17.com --- -Welcome (so admins on my site can access it) (0) Right now, if i go to the cpanel of my site, I can access webmail of any of the email addresses I (4) i think i may asked this question awhile back but i never really got it solved. ok..i had a block (1) Well, i had the idea of logging the downloads from my web in a html file few weeks ago, and i solved and XAMPP as the server version on Windows (7) On my Trap17 account here, I have an .htaccess file with the following declaration which (I think) I need noob detailed help on setting up a email server on windows XP (0) Hello I would like to say thank you for any help you might give me. I'm new to Apache / PHP and (0) Well, my topic title is pretty descriptive. Does GD use much server ressources, is it heavy to run, (4) My Webpage If you check here in my site in my Login block called "user info" at the bottom it server control html component (6) does this sort of feature can be done in php. http://www.w3schools.com/aspnet/aspnet_forms.asp or PHP & Apache Server (7) I want to install PHP. For this I have downloaded Apache Server. But I am not able to configure it. Why won't the db server work? (2) What is it?.... Looking for php, interact, visual, basic, app, server
|
|
![]() Can Php Interact With A Visual Basic App On A Server |
| ADD REPLY / Got an Opinion! | Remove these ADs! | RAPID SEARCH! | Free Web Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|