0
import socket
import sys
import urllib


port = 6669
mac = "e448c7a96170"

try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ip = socket.gethostbyname( mac  + '.rtn.iptv.svt.sciatl.com')
    sock.connect((ip, port))
    print(ip)
    sock.send("getdom;ipg")
    print "Message Sent"
    while True:
        global m;
        m=sock.recv(10000)
    print(m)
    sock.close()
except:
    print sys.exc_info()

Hi folks I am new to the python.I am trying to print the 'm' value.But it is not printing it since the print statement is outside the loop. I am trying to store the received data in a global variable and use it in the later part.But I am not able to do as the 'm' variable is not visible outside.Any help is appreciated. Thank you

3
  • 1
    global m doesn't makes any sense here. global is for functions. Commented Jan 16, 2013 at 22:40
  • @AshwiniChaudhary for within functions. (Deleting this comment in a few when you've edited) Commented Jan 16, 2013 at 22:41
  • @phant0m oh! I missed the 5 minute mark, btw thanks for pointing out the grammatical mistakes in my sentences for the nth time. :) Commented Jan 16, 2013 at 22:51

1 Answer 1

3

Your problem is that your loop will never end - while True is going to be true forever, so print(m) is never executed

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.