Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Results 1 to 3 of 3
  1. #1
    michaelsanford is offline Translator, Web Developer
    Join Date
    Oct 2002
    Location
    Ottawa/Montréal
    Posts
    2,280
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Lightbulb What's the deal with socket paths?

    I was just reading my PHP manual and it says that I can refer to my MySQL database not only by IP address or host nameort but also by a socket path such as localhost:/tmp/mysql.sock which I noticed exists on my machine...

    What exactly is a socket path? I'm trying to wrap my head around the way a file can act as a port. How can I determine the socket listing on my machine (and by extension, find the correct socket for MySQL). Are there advantages-performance or security-to using sockets over ports?

    TIA!

  2. #2
    scruffy's Avatar
    scruffy is offline Notorious Olive Counter
    Join Date
    Dec 2000
    Location
    Soviet Canuckistan
    Posts
    1,726
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One of the most common, and nicest, abstractions in Unix is "everything is a file". For example, check out /dev to see files for all your hard drives, the modem, the OS's random number service, etc. Basically, dealing with something that has a 'pseudo file' representation, whether it's a physical device or a service like MySQL, can then take on the familiar semantics of file I/O.

    A socket can be bound to an IP port, so that it can be accessed via Internet, or to a file path, so that it can be accessed via filesystem calls. Once you have a file descriptor for the socket though, you just use read() and write() calls on it, no matter what it was bound to.

    So, to answer your question - the only advantage to one method over another would be what you're most comfortable programming with.

    What is the robbing of a bank compared to the founding of a bank?
    -- Bertold Brecht

  3. #3
    michaelsanford is offline Translator, Web Developer
    Join Date
    Oct 2002
    Location
    Ottawa/Montréal
    Posts
    2,280
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Cool thanks! :P

 

 

Similar Threads

  1. good deal on ram?
    By THEMACER in forum Hardware & Peripherals
    Replies: 3
    Last Post: October 17th, 2002, 02:41 PM
  2. A really good deal for students!
    By d8n_two in forum Apple News, Rumors & Discussion
    Replies: 4
    Last Post: August 6th, 2002, 04:06 PM
  3. Socket Communications CDMA handset cards
    By Nosh in forum Mac OS X System & Mac Software
    Replies: 0
    Last Post: July 24th, 2002, 01:05 AM
  4. Easy, powerful socket
    By kainjow in forum Software Programming & Web Scripting
    Replies: 0
    Last Post: June 13th, 2002, 07:36 AM
  5. creating socket connections from OsX to classic
    By kgaulton in forum Mac Classic System & Software
    Replies: 1
    Last Post: July 15th, 2001, 06:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •