Hello I'm trying to call a specific object from the socket library, more specifically socket.send and socket.recv. The IDE i'm using is pycharm and its telling me that it cannot find the the reference in the socket library. Here is a snippet of my code:
def http(ip,port):
try:
socket.setdefaulttimeout(2)
a = socket.socket()
a.connect((ip,port))
socket.send("GET HTTP/1.1 \r\n")
giveMeUrInfoz = socket.recv(1024)
print "[+]" + "Huzzah! " + str(giveMeUrInfoz)
print "**********************************************************"
return giveMeUrInfoz
except Exception, e:
print "[-] Unable to grab info" + str(e)
print "**********************************************************"
return str(e)
The pycharm IDE is telling me that it does not recognize the send and recv objects. I know for a fact that the socket.send and socket.recv are valid objects part of the socket library per the following link to python docs :https://docs.python.org/2/library/socket.html.
My question is, why is this not working? I should also mention the purpose of this function in my script is to obtain the web server banner information via get request. I am passing port 80 into the function as well as a valid IP address.