Difference between SoftwareSerial and Serial From the sample code 

#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}


What is the difference between, why use 2 types of calls to make AT command calls.


  SoftwareSerial mySerial (10,11)
  mySerial.begin(10,11)


and


  Serial.begin(9600)


Edit, this answers my question in my own words based on @jfpoilpret response.


It is important to initialize both Serial and SoftwareSerial, since SoftwareSerial is used to send the actual commands to the GSM, and Serial is used to view all the commands and their responses on the debug port of the GSM
The pins on the GSM and Arduino are used to connect the the 2, and pass on actual commands. While the RS232 is only used for debugging. We can however connect a RS232 to USB connector so as to connect the GSM to the desktop(or laptop)
The code in the loop is essential to help convert all actual commands to the debugging RS232 port, and the other way around, so as to enable us to use a tool like cutecom (on ubuntu) to pass commands to the GSM serial input pins.



  Important Note : When using cutecom ensure that you select CR line end to send commands.
All Atmel MCU, on which Arduino models are based, include special hardware for serial communication; this part of the MCU is called USART (stands for Universal Synchronous/Asynchronous Receiver/Transmitter).

Based on the Arduino model you have, you may have only one (eg on UNO) or more USART (leonardo, mega...) on the board MCU.

Each MCU USART is mapped to specific pins of the board, you cannot change those pins.

On Arduino, if you use the monitor to send debug information to your PC, then one USART is used, this is when you used Serial.

If you need more than one serial communication link (e.g. because you have some devices that communicate through serial) but your Arduino model has only one USART, then you have to use the library SoftwareSerial that "simulates" the job of an USART only by software. Hence it is much less optimized than the hardware USART.

One advantage of SoftwareSerial is that you can map it to any pair of pins you like.

Going to your code sample:

if (mySerial.available())
    Serial.write(mySerial.read());
if (Serial.available())
    mySerial.write(Serial.read());


Obviously here, Serial is used for debugging (sending info to the serial monitor of your PC), whereas mySerial is used to communciate with the GSM device.

So this sketch is used to allow you to type AT commands on the monitor, which will then be forwarded to the GSM device; conversely, any strings returned from the GSM device will be echoed to the serial monitor.