I'm still not sure what fsockopen can do and how. Is there anyone that can clear things up for me? Remember, talk simple.
ok lets start from the information you were given:
fsockopen() = "... initiates a socket connection to the specified resource ..."
now lets break down that statement.
initiates means: "starts or opens".
socket means: "one end-point of a two-way communication link between two programs running on the network".
connection means: "the successful completion of necessary arrangements so that two or more party instances can communicate".
specified resource means: the server address or ip number, and port number.
so, fsockopen() starts/opens a two-way link between two programs (one being your php code and the other being a servers address and port) running on the internet by successfully completing necessary arrangements (in this case compatible protocols) allowing the two to communicate back and forth.
it allows your script to talk to a server as a client.
this could be:
- chat
- email/smtp
- http
- data import
- data explort
- ftp
- webdav
- svn
- xml
and alot more.
as codewhite stated, visit the link he posted to the function manual.
also, a good amount of php knowledge is extremely helpful.
Additionally, a good amount of knowledge of the protocol the server you are connecting to is using is extremely helpful, because when "talking to the server" (using fwrite), the data has to be formatted correctly for the server to understand it and allow said communication to process and progress.
There are whitepapers available online for any protocol to learn syntax, line/end-of-line format, and commands necessary for the successful communication.
Lastly, some servers require user authentication so thats needed as well for successful communication.
you want specific examples ?
1. 110mb.comservers has no inbound email for their user accounts, but many people want a contact form so their site visitors can communicate with them. Using a 3rd party email service with remote SMTP, we can use a service like Google's Gmail with fsockopen() to allow users to email the webmaster through a contact form. Additionally, a webmaster can receive automated website information through the same means for manual acount validation or if there is a website problem the script intercepts and sends to the webmaster.
2. Say you are running a webite front end for a online radio station stream. You can use the above for email contact, and you can use fsockopen() to login to the streaming server and read their XML files for current playing song and a list of played songs that updates every time a user refreshes the page or loads the page, and even have it refresh itself.
3. use a php script as an ftp client instead of a 3rd party client.
4. have an online chat service (illegal on 110mb.com)
5. importand export XML/RSS newsfeeds.
6. provide 3rd party version checking, key authentication checking, and allow for automated upgrades (in addition to using fopen).
theres really too many possibilities to mention.
fsockopen() simply allows for two-way communication to any server where you can format the data out in a way the server will understand and successfully process ... you can also request data from the server and logically process it according to its format and content.