Friday, November 14, 2014

Interview Questions on Socket Programming

Socket programming is used to make computers exchange data. It is an uncommon topic and not many programmers come across it in their professional career.
This blog post outlines several questions which might be asked from someone in an interview for a position that involves either writing code for network applications or managing a team of people writing network programming code.

The questions listed here are worth reading and knowing the answers to these questions in general means you have a sound top level understanding of computer networks work.

It is possible to learn network programming in only one hour, just take the Udemy course given below, it is free for a limited time

https://www.udemy.com/tcpip-socket-programming-for-coders-using-csharp-net/#/


1. A host is a machine that is hosting a software capable of communicating over the network. Yes/No?
2. A host is identified by an IP Address which is unique inside a network. Yes/No?
3. In enterprise scenarios, a host name is translated into an IP address by a server called:

  1. DHCP Server
  2. DNS
  3. LDAP Server
4. An IPV 4 IP address is a group of __???__ numbers, each 8 bit in size with a value between 0 to 255.


Demo TCP/IP Sockets Read and Write in C#, Free #Udemy Course, 100% discount from Naeem Akram on Vimeo.

5. We find the IP Address of our computer using a DOS command which is

  1. tracert
  2. ipconfig /all
  3. ipconfig /flushdns
Quick TCP/IP Socket programming for coders is a free course (limited time offer), take the course and learn about socket programming in only one hour.

https://www.udemy.com/tcpip-socket-programming-for-coders-using-csharp-net/#/

6. Every computer contains a finite number of ports which is

  1. 1024
  2. 65536
  3. 99999


7. The client process and the server process must be running on two different machines.
8. A pair of an IP address and a port number is used by the server process to listen for incoming connection requests, this pair is called an __???__

9. A client processes's attempt to connect with a server process can fail for various reasons including


  1. Windows firewall has blocked the client process or server process from using the network.
  2. Server IP address supplied to the client is wrong
  3. The server process is not started at all
  4. All of above


10. Telnet is a free utility, it is always enabled on every PC. Yes/No?
11. We will enable Telnet __???__ from the "Add Remove Programs" dialog "Turn Windows features on or off"

https://www.udemy.com/tcpip-socket-programming-for-coders-using-csharp-net/#/
Only one hour is all you need to know answers of the questions listed here and get loads of more interesting information about computer networks. The course link given above is free for a limited time, it won't cost you anything and you will learn loads of new stuff so just go ahead and sign-up.

Thursday, November 13, 2014

Learn TCP/IP Socket Programming in 1 hour


Demo TCP/IP Sockets Read and Write in C#, Free Udemy Course from Naeem Akram on Vimeo.

Network programming is a very important topic, it is also considered a bit complicated. Most of the tutorials and lessons already available on the internet tend to make this topic even difficult to learn.
This Udemy.com based online course is totally free for first month, and it makes socket programming using C# really easy.

By taking this free Udemy course, you will be ready to write network communication applications within only one hour!

You will learn a lot of other useful things during this course, for example how to find the IP address of your PC using command prompt and how to use telnet utility.
More techniques such as finding an IP address through a host address and selecting the active IPV4 address of your PC automatically will also be covered in this course soon.
I will also add videos about how to handle multiple client nodes and how to add/remove clients from the list of connected ones as well.

I've uploaded same demo video to Youtube as well.



Please join this course, watch it, and provide your highly valued feedback. It will be very helpful for me.

The author is a professional computer programmer with socket and network programming experience in C++ and C# languages on Windows platform, and same in Java language on Android platform as well.

The author loves to blog, which is evident by the posts in this blog which have been written over the course of six years(on time of this writing). On the side, this author has got a very nice kitchen garden on the roof top and loves to cook delicious Pakistani food as well. Most importantly, I'm a proud and loving father of two children as well :)

So please join this course about TCP/IP socket programming using C#.Net. I am sure it will be helpful and you will learn a lot of very useful programming techniques and some really cool theory.

Wednesday, October 15, 2014

Trick SQL Interview Question and team work

Just yesterday I was sitting with friends at our legendary Firdos Market flat 94/H. Adeel my brother told us about a query which an interviewer had asked him to solve, it was dinner time so we handed the query to Zaheer Chaudhary who'd already eaten a couple of hours ago.

After the dinner, Aweas Dar who's Adeel's class fellow (Zaheer is also a class fellow) opened SQL Server and created table structures needed for the operation. The trio I just mentioned graduated computer science from Univerty of Gujrat(UoG) in 2012.
All of us sat down and started talking about the query, the problem statement is given below:
subjects-table-design"
Suppose we have two tables, students and subjects. The students table contains two fields id,  and name. The subjects table contains three fields: id, std_id, subject.
students-table-design
We need a query to which when executed produces the result set with columns describing how many courses each student is taking. In a better version of result set we will have a student id, student name, and number of subjects.
"



Table structures are also given above for reference.
Everybody knew that we will need to do a count on the subject field  of subjects table. So we wrote a couple of queries, poked some jokes on each other and ultimately achieved the desired result.
Unfortunately I couldn't save various versions of the query as it evolved.

Aweas also keyed in dummy data rows, a screen shot image of student table data and subjects table data is given below.

select-top-students

select-top-subjects

Next it occurred to us that we will need to use SQL Group By in this situation. Possibility of using a join was ruled out quickly and finally the SQL where clause was also needed.
The final SQL query was made even beautiful by adding an ORDER BY clause, the result of our quick team work is the SQL Query given below

SELECT students.id AS StudentID, students.name AS Students, COUNT(subjects.subject) AS NoOfSubjects
FROM subjects, students WHERE subjects.std_id=students.id GROUP BY students.name, students.id
ORDER BY StudentID

There are small emotional holes that we leave unplugged due to laziness, we could have left the query unsolved and keep thinking about it for a long time. Some of us would even get a guilty feeling that they were unable to sort it out. This event shows the importance of team work, and how a cooperative thought process can help us to solve puzzling questions cracking jokes.

Sunday, October 5, 2014

Framework vs IDE

Microsoft Visual Studio 2012 is an IDE(Integrated Development Environment), whereas Microsoft .Net 4.5 is a Platform.
Android is a Framework/Operating System, and Eclipse is an IDE.
I started off with solid examples of framework and IDE since I believe these will facilitate further explanation.
Microsoft Visual Studio 2012

Putting the term IDE in perspective?

It is a group of various tools  which work together to compile a computer program, and create an executable package.
dotnetframework-4

For example, on Windows we have Microsoft Visual Studio in which you can create a project and write some code. You just need to click a button or two and an execute-able file with extension .exe will be generated which you could take to any suitable computer and run.

Another example Android platform, you can write some code in C++ or maybe Java and use an IDE of your choice which might be Eclipse, Android Studio, or any other and click a few buttons, an executable package or .apk will be created for you which you may copy to any suitable Android device, install and run right away.
android-os-logo

Explaining Integrated Development Environment

When we click a button inside an IDE and order it to create a nice package for us, a lot of things happen in the background. For example code of both .Net and Java languages need to be converted into a "byte code" which is then interpreted by the Java Machine/Common Language Runtime. There is a software tool which performs this task.
eclipse-juno-ide

But before going on with the conversion, someone needs to make sure that the code supplied as the brick and mortar of your awesome software is correct or not. Incorrect code cannot be used to generate correct software. You must have guessed it by now, there is a separate tool which performs the job of error checking and compiling.
Yet another tools is the notepad like editor in which you type code, it automatically makes the code look pretty and colorful. This part is called "pretty printer" and it too is a separate tool.
There are numerous other tools, but let's just stop here and imagine that we got only three tools

  1. One that makes the code look pretty as we type it
  2. One that's responsible for making sure that our code is correct
  3. One that makes a software package (.exe or .apk) out of our correct code
All three of these tools need to work together and cooperate, and do their job in an integrated fashion so that you can retain your development job.
When various tools work together in an integrated fashion, we get an integrated environment for development. Just to make things look uglier, an Integrated Development Environment.

visual-studio-code-pretty-printing


Framework Explained
A framework is a set of various software tools and standards which work together and make a computer programmer's job easy. A framework might contain things like
  1. Application Programming Interface (API)
  2. Just in time (JIT) compiler
  3. Virtual machine (JVM/CLR)
  4. Standards for making various language work together e.g. CTS or common type system(C#, F#, C++/CLI)
For a detailed description of framework, examples, and comparison with API please see following article:


I'm working as a full time freelance programmer through ODesk.com, I have a strong profile over there. Feel free to ping me if you need an Android app. Elance widget is given on top right of the page, for ODesk follow the link given below:


https://www.odesk.com/users/~012d73aa92fad47188

Saturday, October 4, 2014

c++ string to char array

C++ standard template library string A.K.A std::string was a novel concept back in the day(80s, 90s). Now we see every language be it Java or C# or Ruby contains an excellent implementation of string and similarities between the modern string libraries can be traced back to yesteryear's string.h header file.

It is important to note that the std::string classes were actually a wrapper around C style null terminated character pointer string.

Even the apparently sophisticated BSTR of COM era are just a sequence of characters with some meta data(length of string).

c++ string to char*

Since we know every std::string actually contains a char * buffer in the background, there must be some way to covert c++ string to char array.

c-plus-plus-string-char-array-code


The good news is that there is a function in std::string class which lets us retrieve the const char * which is in the background. The method is called
c_str
An exact example in code about how to use std::string.c_str function is given below.

Code C++ string to char * or char array

using namespace std;

#include<string>
#include<iostream>

int main(int argc, char* argv[])
{
 std::string strILoveYou = "i<3U";// new object of std::string

 const char * szMe2 = strILoveYou.c_str();// new object of c style null terminated character pointer

 cout << strILoveYou << endl; 
 cout << szMe2  << endl;

 return 0;
}// code highligting with http://tohtml.com/cpp/


You must have noticed that the const char * retrieved this way is read only. If you want to extract a changeable string out of std::string we'll need to add a couple of lines to the code. We will sue strcpy C function, some might argue that this is not true C++ but I say everything from C is in the genesis of C++ so there's nothing untrue to spirit of C++ if we use functions from C language which is the mother of all languages. The new code will look like

using namespace std;

#include<string>
#include<iostream>

int main(int argc, char* argv[])
{
 std::string strILoveYou = "i<3U";

 const char * szMe2 = strILoveYou.c_str();

 char * notConstantCharPtr = new char[strILoveYou.length()]; 
 strcpy(notConstantCharPtr, strILoveYou.c_str());

 cout << strILoveYou  << endl; 
 cout << szMe2   << endl;
 cout << notConstantCharPtr << endl;

 return 0;
}// highlight with tohtml.com/cpp

HAPPY CODING FELLAS!!!

I'm working as a full time freelance programmer through ODesk.com, I have a strong profile over there. Feel free to ping me if you need an Android app. Elance widget is given on top right of the page, for ODesk follow the link given below:


https://www.odesk.com/users/~012d73aa92fad47188