Wolfram Alpha was launched in May’09. Its not a search engine, its “answer” engine. It was made by Wolfram research, founded by Stephen Wolfram( child prodigy I must say, read about him on wikipedia ), a mathematician and physicist.
This site is amazing, it is an online service that answers factual queries directly by computing the answer from structured data, rather than providing a list of documents or web pages. You type in query like “e^2” and it gives you answers in graphs, value etc. if you type in “chocolate” it will give its nutritious facts. This site amaze me from the very first time I have seen it and to be more specific the answers it gives.
They have APIs waiting to be used and give some awesome website. You can create a Pro account for more benefits. I personally feel this thing can do something to internet what Hotmail did to email.
Pinterest is a new website launched in March’10. Instead of going the traditional way, it used people’s interest as its base.
Login is by invite only for now. You can pin your interests, see and re-pin other people’s interest, follow people having same interest. It do not give the social experience which Facebook gives but its of great use for companies and individual products. They can conduct survey for their products or analyse their products.
There is also one thing I would like to focus on- design. Look at the vertical layout, jQuery plugin Masonry gave it that look. Its kind of nice and new design.
They have APIs for sharing and all. Lets see who comes up with something new using it. Try it, see if you like it.
Referring to previous post, we will continue with same code. In this post we will try to handle multiple clients. You can read rest of the post on my personal website, here is the link.
My personal website is up and all new blog posts will only be available on https://neerajkhandelwal.com.
We will be understanding the basics of socket programming using Python.You may be thinking why socket programming? Well, its because if you need to send data over a network you need to know about socket. The HTTP websites runs on port 80. Each website has a IP adress. So when you request for a website actually your browser is trying to get data from someipaddress:80. 80 is default port that browser uses, otherwise specified. You might have used Apache. What it does it creates server(we call apache server) and binds it to 127.0.0.1 and port 80. 127.0.0.1 is called loopback address as it tells the browser to look in the consumer’s computer only instead of searching web.
Lets start, first of all socket is a connection point like your phone. You connect to some socket (someone on other side of phone) and send and receive message or data (chat).
Requires: Python 2.6 + Using
: Lets try to create a server first.
# Import all from module socket
from socket import *
# Defining server address and port
host = '' #'localhost' or '127.0.0.1' or '' are all same
port = 52000 #Use port > 1024, below it all are reserved
#Creating socket object
sock = socket()
#Binding socket to a address. bind() takes tuple of host and port.
#Listening at the address
sock.listen(5) #5 denotes the number of clients can queue
#Accepting incoming connections
conn, addr = sock.accept()
#Sending message to connected client
conn.send('Hi! I am server') #send only takes string
#Receiving from client
data = conn.recv(1024) # 1024 stands for bytes of data to be received
Now a client.
from socket import *
host = 'localhost' # '127.0.0.1' can also be used
port = 52000
sock = socket()
#Connecting to socket
sock.connect((host, port)) #connect takes tuple of host and port
data = sock.recv(1024)
sock.send('HI! I am client.')
Everything is explained in comments.
- The program above is waiting for type of programming. Look at the send and recv part in both programming, if server is sending something client must always know when server will send and vice versa or it should wait for that. Of course if you don’t want to drop anything you are sending.
- # is used for comments except the first line it is for telling where python program is. Use path to python.exe on Windows.
- Always use sock.close() to close the socket otherwise socket is in use error will be thrown by python. You may also see it if the program terminates in between.
- 5 in sock.listen is of no use right now as the server.py will terminate as soon as it is done with first client.
- sock.recv() waits till it does not receive something.
- print data will not work with python 3.0+. Use print(data).
There will be more on it. Till if you want to read more about it, see here