Followers

Monday, November 29, 2010

Some common tech jargon:-

Hello,

What I am about to discuss are very trivial technical points for programmers, But just for the sake of Jargons :-

1) Off-by-one error (OBOE): suppose you want to traverse an array from beginning to end. lets say its size is  100. And in the implementation programming language, the index starts from zero.

The following code segment demonstrates OBOE:-

for(i=0;i<=100;i++)

{

----------------------- some code

}

We end up traversing 101 elements. the array ranges from o to 99.

Its very common in C language.

2) Fencepost Error:-

This is an error associated while answering questions such as:-

If you build a straight fence 100m long with posts 10m apart, how many posts do you need?

At first sight we would say:- 100/10 = 10 posts are needed.

But looking closely we find that the answer is ((total_length/individual_length)+1) posts are needed.

See you guys,

Bye


Sunday, November 28, 2010

REASONS FOR: java.net.SocketException: Permission denied: connect

Hello friends,

Was trying to fetch response from a website, through the use of Socket class in a Java program.

Socket s1=new Socket("www.oracle.com",80);

Was getting the error:-

java.net.SocketException: Permission denied: connect

Solution:

The most probable reason for this, is that we are trying to access a port which is below 1023, which requires special privileges. In my case, I did not login as the administrator. Hence the error.


If I run the same lines of code , logged in as administrator, there will be no error.


Hope it helps,

Ashish Mishra