Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

websocket

General discussions related to php

Moderators: macek, egami, gesf

websocket

Postby minashij » Fri Sep 14, 2012 8:32 am

I,m confused if there is any way to do things on websocket connection that is done before on http request, for example execute a sql query on a websocket connection that stablished before? :oops:
minashij
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Sep 14, 2012 8:24 am

Re: websocket

Postby NigelRen » Sat Sep 15, 2012 11:56 pm

A lot of software works by sending requests to various ports ( or sockets ), but usually each package has it's own 'language' if you'd like to call it that. The client software ( which is what your talking about ) needs to know what commands to use and how to interpret the responses.
If you look at MySQL - it uses port 3306 by default, so if you know how to communicate with MySQL, you can talk to that port and execute SQL. Note that when you connect to MySQL from PHP - you use
Code: Select all
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// some code
?>

The 'localhost' is the server to connect to and this will connect using the default port - 3306. PHP acts as a client to the MySQL database and sends commands and receives data through this socket.
NigelRen
php-forum Active User
php-forum Active User
 
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.