Basically, a socket is a channel through which you can send requests to a program running on a remote server and receive responses from that program. In PHP, you send requests using fwrite() or fputs() and read responses using fread() or fgets(). Which program would respond to your call, depends on which port you are using to open a socket. For example, calls to port 80 are usually handled by an HTTP server (such as Apache or IIS), calls to port 443 are also handled by an HTTP server, but the server requires that the request be encrypted, calls to port 25 are handled by a mail transfer agent, etc.
2007-03-21 08:13:19
·
answer #1
·
answered by NC 7
·
1⤊
0⤋
I believe that it is used to open files over the internet. fopen, etc opens files on your own server while fsockopen can open files on other websites.
I've seen it used for paypal's IPN responses (Instant Payment Notification). The script in that case requests a file from paypal, which in turn verifies that the information is correct.
Would be excellent to use for grabbing XML information from other websites. You could then parse the result using PHP.
2007-03-20 09:16:32
·
answer #2
·
answered by Clinton G 2
·
1⤊
0⤋
It opens a socket to send data. At a low level, reading and writing data over a network connection using sockets is very much like reading and writing to a file.
2007-03-20 09:58:59
·
answer #3
·
answered by Pfo 7
·
0⤊
0⤋
Network sockets, an older term that is mostly transparent within Windows (WinSock is part of Windows' TCP/IP stack) but sockets are elemental to older style (still heavily used) UNIX interprogram communications.
2007-03-20 09:18:49
·
answer #4
·
answered by Andy T 7
·
1⤊
0⤋