ID #119

I can't get the python socket module to work?

Applies to: Grid System

The python socket module is installed and works. Here is an example of how to use the socket module under Python 2.1

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 50007))
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data: break

You can run this script on the command line like so:


Or, if you add the line


as the first line of the script, and it is executable by you

chmod 750

then you can run it from the command line like so:


or as a CGI script (assuming it is in your /htdocs/www/cgi-bin directory)


Last update: 2010-09-29 16:59
Author: FAQ Admin
Revision: 1.2

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 0 (0 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ