sockets-why use sockets?

Discussion in 'PHP' started by arpit13, Aug 3, 2010.

  1. #1
    hi, i was wondering why sockets are used?
    plz don't refer me to the php.net site i went their and everything i read just flown over my head :p .

    i just want a brief 2-3 lines description.

    please tell me :).

    thx
     
    arpit13, Aug 3, 2010 IP
  2. Andrew J

    Andrew J Peon

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sockets are used for connecting to FTP, SSH, etc. and executing commands. If you don't need it don't use it.
     
    Andrew J, Aug 3, 2010 IP
  3. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #3
    lol, my title is wrong ,i know.

    anyways wat kind of commands are executed by sockets?
     
    arpit13, Aug 4, 2010 IP
  4. flexdex

    flexdex Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It is very doubtful that you get the right answer if you are not sure about what your question is. This question has nothing to do with PHP and is actual a "network" question.

    But anyway, a (internet) socket is a virtual bidirectional communication endpoint between two or more other (internet) sockets and is executing no commands. A socket is more or less restricted to a protocol, for example TCP/IP or UDP, and a IP address a bunch of legal port adresses or a local domain socket file handle. A application using that socket to send and receive data. There are other options of sockets, but those mentioned fit your question most.

    For example. If you using a browser, what you obviously doing at the moment, the application is that browser. The browser is using a network socket on your computer to communicate with a socket what is used by the web server who is processing the page you are viewing at the moment.

    Take your time and try to improve your question so we have a chance to improve our answers.

    flexdex
     
    flexdex, Aug 4, 2010 IP
    arpit13 likes this.
  5. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #5
    oh nice answer flexdex.

    well i mean to say for "wat purposes php sockets are used?"

    but i was a bit confused of wat sockets are as well.
     
    arpit13, Aug 4, 2010 IP
  6. flexdex

    flexdex Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    PHP sockets functions, or the PHP socket commandset is used by PHP applications who needs to communicate with other software applications. There is a wide variety of how sockets are used by php applications and due to the convenience, the php file processing commands and some other php file releated commands have (if enabled) access to sockets also.

    For example. If your php application needs weather data for a nice weather forecast widget on your website, that weather data is mostly requested thru a socket from a weather data service.

    Regards

    flexdex
     
    flexdex, Aug 4, 2010 IP
  7. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #7
    oh ok.

    so u mean that socket can be used to get data from other sites.means they can be used as bots.

    thanks a lot i will find more applications for them on google.
     
    arpit13, Aug 4, 2010 IP
  8. flexdex

    flexdex Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    PHP is not well know as a basis for an application with a runtime longer than 30 seconds. PHP is bettern known as a basis for web based applications, like presenting web pages.

    PHP itself is just a template engine, a hypertext preprocessor. But with all of its whistles and bells it will often misinterpreted as something else.

    If you plan to create a bot, please look at C, C# or even PERL. This does not mean that you can not create a web frontend for your bot with PHP.

    flexdex
     
    flexdex, Aug 4, 2010 IP
  9. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #9
    hmmm....

    just 30 secs is low.

    but atleast i come to know purpose of sockets.
     
    arpit13, Aug 5, 2010 IP
  10. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #10
    Sockets provides a layer in transmission from one place to another.

    It can be remote or local.

    In a unix environment, you can have sockets that acts as a bridge between 2 programs without the use of named pipings.

    Sockets can also provide a protocol, so server-client can communicate.
     
    Kaizoku, Aug 6, 2010 IP
  11. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #11
    thx for more apps of sockets ;)
    i have started to learn sock functions.
     
    arpit13, Aug 7, 2010 IP
  12. militarysmurf

    militarysmurf Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    40
    #12
    Another unmentioned usage is Inter Process Communication (IPC). You can create sockets between 2 forks of the same script to communicate in between the scripts.
     
    militarysmurf, Aug 8, 2010 IP