Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 11th, 2002, 10:42 AM
lpsz lpsz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Madrid
Posts: 0 lpsz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking newbie stupid socket question

i am a newbie with python and i did this program copied from internet (on debian woody with python 2.1):

# sockets
import sys
from socket import *

#create an INET, STREAMing socket

Sock = socket(AF_INET,SOCK_STREAM)
Sock.connect(('www.google.com',80))

#now connect to the web server on port 80

# - the normal http port


msg = ''
while len(msg) < MSGLEN:
chunk = Sock.recv(MSGLEN-len(msg))
if chunk == '':
print "socket connection broken"
sys.end()

msg = msg + chunk
totalsent = totalsent + sent


print msg

sys.end()


i get this error from python :

Traceback (most recent call last):
File "mailer.py", line 7, in ?
Sock = socket(AF_INET,SOCK_STREAM)
NameError: name 'socket' is not defined

so, where is defined socket if not in sockett module?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > newbie stupid socket question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway