A socket is a certain connection of data, A connection between two peers or a server
to create a connection. There are two types of known connections by mIRC, the TCP protocol
and the UDP. A simple TCP connection is what were using on usuall Applications, like
mIRC and Internet Explorer. the UDP protocol is based on Packets of data, which means
that handling should be known at first, Applications like ICQ, Kaaza, Napster (rip) uses
or used UDP before.
As for any socket, There is a certain Protocol and common methods for general use of the
socket. As an exemple mIRC has a protcol, ICQ has a protocol, and HTTP is a protocol which
i will focus on here.
While i'm explaining (or trying to) about this Protocol i'm assuming that you have a bit
of Exeprience in sockets, Events and identifers.
- HTTP (Hyper Text Transfer Protocol)
Far as users know the HTTP protocol, is thorugh Internet Explorer, Netscape and maybe
Telnet, Here's a qoute from RFC 2616:
The Hypertext Transfer Protocol (HTTP) is an application-level
protocol for distributed, collaborative, hypermedia information
systems. HTTP has been in use by the World-Wide Web global
information initiative since 1990. The first version of HTTP,
referred to as HTTP/0.9, was a simple protocol for raw data transfer
across the Internet.
So basically, we send Data to server, Server sends us data back. pisa cake?
In order the server will understend our requests, a certain kind of data or any other
detail we must provide the server exectly what, Here are the common methods:
GET webpatch/file [HTTP/1.x]
The GET request tells the server that what file do we want and in what Directory
is it located, usally the GET command it used for html files and binary files.
The HTTP/1.x (x as number, mustly 0), tells the server we want a HEADER first.
The HEADER contains the CODE of the event (OK, FILE MOVED, FILE NOT FOUND, NOT
AN AUTHORIZED REQUEST and so on), The file size (if it was found), server's local
time, VIA data, and fianlly a CRLF signal that means the file is now being sent.
The HEADER can contain Cookies, Authorzation requests, Relocations for the Explorer
to know the file has been Moved, but thats another thing.
POST webpatch/file [HTTP/1.x]
Almust like the GET method, only this one is used with certain kinds of files like
CGI, PHP, ASP and other types that works with an engine or so, I'm not fully
aware of its basic conecpt, but me and many others uses it on those kinds of files.
This one simply requests for the HEADER of the file, the server will not send the file
and will send nothing but it's header (read the fallowing methods)
Host: current host
This method tells the server its host, Its quite weird telling the server its own
address but some HTTP servers requeirs that method in every request.
Accept: acceptble files
This method a bit more complicated then the others, Although it could be shortcuted
into a simple */* signal. Must clients sends the longer one, that speceifes
html and text files, what is applicatable and whats not and types of images.
According to RFC's, this method tells the server that we want the connection to
remain or to be closed right away.
in the end of every method we must specify a CRLF signal used with $crlf or with the -n
switch in the /sockwrite command
Basic Client to Server HEADER:
GET /path/filename.html HTTP/1.0
After the HEADER (if you requested for it) the actuall file is being sent, Ready with the ON SOCKREAD event we save
the data into a file, a castum window or just echo it, If you've requested a Binary file you should use the &binary
type to save data and to write it to a file (/help /bwrite), but there is a catch!
If we've got the HEADER that is ASCII, which means a Binary file will contain ASCII code that will screw the file.
To avoid writing the HEADER to the file, make sure you save the HEADER into and the Binary part into
&sockread and into the actual file, use the CRLF singal that seperates the HEADER from the file.
If you'd like to know more about HEAERs (Client's or Server's) read RFC's about HTTP and its method and download
snippets about HTTP for you to know more about the protocol.