Python SOCK_STREAM over the Internet

I have simple programs for the socket client and server, which it does not work over the Internet

# Echo server program
import socket
import ImageGrab

HOST = ''                 # Symbolic name meaning all available interfaces
PORT = 3000              # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
data = conn.recv(1024)
print data
conn.close()


# Echo client program
import socket
import ImageGrab
#destnation ip
HOST = '127.0.0.1'    # The remote host
PORT = 3000              # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('Hello rushikesh')
s.close()
print 'Received'#, repr(data)

When we try to get it to work over the Internet, it cannot connect. The program is shown as above, only the ip destination replaces my ip friends.

When working on localhost, it works fine, but does not work over the Internet ...

I wrote a program using SOCK_DGRAM, it works over the Internet only for small pieces of data. I want to transfer an image using it, so I wrote it with the help SOCK_STREAMof an image transfer that worked successfully on the local host and did not work over the Internet. So I wrote a simple program, but still showing the same problem

Can someone please check me out through this ...

+2
1

, , , . , , NAT , .

, telnet , , :

telnet 127.0.0.1 3000

telnet , . , - ( , , ).

+4

All Articles