Thursday, March 24, 2011

Socket Programming - Part 1

Reference: http://www.tenouk.com/cnlinuxsockettutorials.html

Port Numbers
  • 16 bit integers
  • So a maximum port numbers are 2^16 = 65536 (0 to 65535)
  • Unique with a machine/IP address
  • Each service/application/daemon will have their own port number 
  • Required to make a connection (along with its host IP address)
Server & Client Port Numbers
  • Connection is defined by: (Server IP and Port number) + (Client IP and port number)
  • Server Port numbers are low numbers in the range 1 - 1023 (called as WELL KNOWN PORT NUMBER)
  • Accessible only by Administrators (roots, in linux)
  • Used for authentication
  • A server running on a well-known port lets the OS know what port it wants to listen on
  • Normally, client port numbers are higher number starting at 1024
  • Client normally simples lets the OS picks a new port that is not already in use.

Monday, March 7, 2011

Background and Foreground Process

1. When you run a command (process), you can make it to run as a background process using $<cmd> &
2. If you forget to make that command as background, and if you feel you should do it now, then
- Press CTRL+Z (Suspend that process)
- $> bg disown 1 (make that process to be a background
3. Now if you want to check the list of background processes, type $> jobs
4. If you want to bring the background process to foreground, then type
$> fg %1
Again to make it a background process,
$> bg %1