16 September, 2014

What happened when I heard about a raspberry Pi



The enthusiast inside me was just sleeping for a while (possibly around 3 years due to the damn corporate IT culture). And technically that was the reason why there wasn't enough posts recently. Suddenly last month on a trip to Coorg with @asuthoshjg & @nikhilkv, I heared about this little nasty motherboard from @asuthoshjg. The whole reason for the raspberry pi to hit our conversation was just my concern about a 4GB SD card in dslr that will easily run out of memory before we reach Coorg via Mysore. And pi just got hooked enough into my brain that browsing about it was the first thing that I did when reached back home after a sleepless night of driving and hunger.

The one best paragraph that explains everything about the pi in their community website is added below.

The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It is a capable little computer which can be used in electronics projects, and for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn how computers work, how to manipulate the electronic world around them, and how to program.


It was one of the interesting things that I heared recently apart from the understanding that Saturday and Sunday are holidays at my workplace (sigh - literally). The another thing that increased my anticipation was that pi was available for online purcase at lot of sites. And I started getting excited about a pocket cpu that is powered by ARM6 700 Mhz processor with 512MB RAM, 4 USB ports, ethernet port and hdmi out at 4k-5k along with accessories. The plan was to replace the  plan of purchasing a vaccum-cleaner ( countless requests from my mother since last months) with the raspberry Pi. 


The funniest part was, Pi will just improve the count of number of computers (used and unused) at my home by 4. Four is a good number, by the way. It was not the Pi alone, but it was the enthusiasm and same old interest to these kind of stuffs when i was at my college, that is coming back to home along with the Pi soon.


Hopefully another post will be ready soon in a week when I get my hands on the Pi...




Read rest of entry

27 January, 2011

python xmlrpc : a simple client server connection mechanism with greater possibilities

A byte of theory . . .

XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. This module supports writing XML-RPC client code; it handles all the details of translating between conformable Python objects and XML on the wire.

A byte of surprise . . .


Here the xmlrpc library of the python does the magic, by leaving the  programmer give maximum attention to logic by freeing him from the concepts of the sockets, binding, listening, accepting, etc ... which are the primary constraints while developing a  network based program. Remote Procedure Call (RPC) mechanism allows the client to call any function defined and registered as 'remote' in the server.

A byte of reality . . .


xmlrpc library offers communication between the client and server in such a way that, we can define functions in one machine (say a server) and access those functions from the other machine (say a client). Here the communication occurs in two ways.
    >< client calling the remote server function can 
           pass arguments to it. So the server recieves this 
           arguments 
   ><  Server can transport some data as the return 
           value of the function that the client called

A byte of practical . . .


    Inorder to make the client and server communicate together we need to create the server object and client object with the ip and port of the server. Here i am running the client and server on the same machine. You can replace 127.0.0.1 in sample code with the ip of the server where you need to connect the clients. Port should be greater than the 1024.

server program

   import xmlrpclib
   from SimpleXMLRPCServer import SimpleXMLRPCServer
   def add(a, b) :
         return a+b
   server=SimpleXMLRPCServer(("127.0.0.1",9009))
   server.register_function(add)
   server.serve_forever()


In server program we have to create the object of the server with a method called SimpleXMLRPCServer() with parameters as ip and port. Then the function has to be registered inorder to access it remotely. The serve_forever() function is used to put the server wait for the client request infinitely.
client program
    
    import xmlrpclib
    server = xmlrpclib.ServerProxy('http://127.0.0.1:9009')
    a=input("No 1: ")
   
b=input("No 2: ")
    result = server.add(a,b)
    print "Result  :  "+result

In the client program we will use the ServerProxy() method to specify the details(port, ip) of the server which is having a function named add() which can be called remotely. So two integers a,b are passed as parameters to the remote function. Remote function calculates the sum and returns the result to the called function.

I felt this xmlrpc library as the most awesome mechanism provided by the python. It makes the programming to the very simplest extent so that the users can give maximum attention to developing logic, instead of worrying about the networking constraints and errors related to it...



 
Read rest of entry

29 April, 2010

How to find the open ports when you get connected

This post is all about the open ports created in your system. This ports are mainly tcp or udp ports. 

Ports below 1024 are reserved for common services, and only root can use them. Standard port numbers can be found in /etc/services. 

Take your terminal and type  in as follows to see them

$sudo gedit /etc/services

The maximum number of ports is 65k, so you have more than enough Internet ports for all your services. Here are some useful utilities. Netstat is a command that will list both the open ports and who is connected to your system. You should run it like this:

$netstat -an | more

This way you can find out who is connected to which service. Another interesting command is the fuser program. This program can tell you which user and  process owns a port. For example, the following command will tell you who owns port 0
$fuser -v -n tcp 0


Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger