how to import the socket function ? in every os should be:
or
Code:
from socket import *
at this part u can import what u want for example:
Code:
from socket import connect
ok now the library was in our source lets make a socket
Code:
sck = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
this will make tcp socket with the first import way
look this case that comes with the second import
Code:
sck = socket(AF_INET,SOCK_STREAM)
now connect the socket to a server by using the second way to create a socket
Code:
host = "google.gr"
port = int(80) #or skip that int its the same
sck . connect((host,port))
another way for it:
Code:
sck.connect(('google.gr',int(80)))
now lets send data to the server
Code:
data = "GET / HTTP\1.1\r\n\r\n"
sck.send(data)
now lets recv data from a server
Code:
data_buffer = sck.recv(1024) # how many bytes we want to recv
print data_buffer #to see the data
thats the most important things about the sockets
advanced tutorial for more things like backdoors and that staff in python will come soon
stay tunned