MySQL Protocol Basics for PurePerl
Writing MySQL Protocol Packets in PurePerl – Part 2
Writing a Perl Module
Foreword: In this part of the series, I talk about MySQL Protocol Basics for PurePerl.
By: Chrysanthus Date Published: 27 Jan 2015
Introduction
You should have read the previous part of the series before coming here as this is a continuation.
Connection States
Communication between the client software and the server is in two phases called the Authentication Phase and the Query Phase. Communication is done in data packets, which are of different lengths. A packet is a series of bytes (characters). In a conversation, packets are form, and they moved between client and server. The following is a flow diagram of the packets (except for connect which is not a packet).
In the authentication phase, the client software connects to the server (software) using a socket and port; this connection process does not really use a packet. If the server accepts the connection, it sends a greeting (handshake) packet to the client. The second arrow in the diagram shows this. The greeting packet contains a scrambled message from the server.
In a special way, the client software combines the scramble message with the password of the user. This combination and the user name is sent in a packet, by the client, to the server as a Credentials (authentication) packet. After processing the packet, the server (software) sends either an OK packet or an ERROR packet to the client (Auth-Result in diagram). The OK packet here, indicates to the client that he is accepted to converse. The ERROR packet means either there was an error in the credentials packet or the human user is not known by the server.
The user may not be conscious of these four communication processes (arrows in diagram). All he knows is that, he has to type in his username and password in the client program, and send the information to the server; he then waits to know whether or not he has been accepted to carry out his conversation. However, deep down in the communication, those 4 low level programming processes musts take place. These are indicated by the top four arrows in the diagram.
The Query Phase
If the client software is accepted to converse, it goes into a cycle of conversation. This phase is indicated by the last two states in the diagram above. The client sends a query (command) packet to the server. The server replies with one or more result packets.
That is it for this part of the series. We stop here and continue in the next part.
Chrys
Related Links
Internet Sockets and PerlPerl pack and unpack Functions
Writing MySQL Protocol Packets in PurePerl
Developing a PurePerl MySQL API
Using the PurePerl MySQL API
More Related Links
Perl Mailsend
PurePerl MySQL API
Perl Course - Professional and Advanced
Major in Website Design
Web Development Course
Producing a Pure Perl Library
MySQL Course
BACK NEXT