On Sunday, March 29, 2015 at 2:27:59 PM UTC+5:30, bobbdeep wrote:
> I am trying to communicate between a server and client using TCP sockets. 
> 
> Server code:
> 
> import socket
> import sys
> 
>     # Create a TCP/IP socket
>     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>     # Bind the socket to the port
>     server_address = ('my-server-ipadress', 1999)
>     print >>sys.stderr, 'starting up on %s port %s' % server_address
>     sock.bind(server_address)
>     sock.listen(1)
>      try:
>             print >>sys.stderr, 'connection from', client_address
>     
>             # Receive the data in small chunks and retransmit it
>             while True:
>                 data = connection.recv(16)
>                 print >>sys.stderr, 'received "%s"' % data
>                 if data:
>                     print >>sys.stderr, 'sending data back to the client'
>                     connection.sendall(data)
>                 else:
>                     print >>sys.stderr, 'no more data from', client_address
>                     break
>                 
>         finally:
>             # Clean up the connection
>             connection.close()
> 
> Client code:
> 
>     from socket import *
>     
>     clientsocket = socket(AF_INET,SOCK_STREAM)
>     
>     clientsocket.connect(("my-server-ip-address",1999))
>     
>     recv = clientsocket.recv(1024)
>     
>     print(recv)
> 
> It is working fine on a local connection. The problem I am facing is when I 
> run the client code on my laptop (using my home wifi network)and try to 
> communicate with the remote server, it is not able connect to the server. 
> What could be the problem ? Any changes in the code required, or do I need to 
> disable firewall on my laptop ?
> 
> The error I get is, error: [Errno 10060] A connection attempt failed because 
> the connected party did not properly respond after a period of time, or 
> established connection failed because connected host has failed to respond

Thanks guys everything worksfine.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to