Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88251
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-03-29 01:57 -0700 |
| Message-ID | <fcccc2e0-b554-424a-a24f-df6b86f8b3cb@googlegroups.com> (permalink) |
| Subject | TCP sockets python timeout public IP adresss |
| From | bobbydeep <anudeepsm@gmail.com> |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
TCP sockets python timeout public IP adresss bobbydeep <anudeepsm@gmail.com> - 2015-03-29 01:57 -0700
Re: TCP sockets python timeout public IP adresss bobbdeep <anudeepsm@gmail.com> - 2015-03-29 03:03 -0700
Re: TCP sockets python timeout public IP adresss mm0fmf <none@mailinator.com> - 2015-03-29 11:14 +0100
Re: TCP sockets python timeout public IP adresss bobbdeep <anudeepsm@gmail.com> - 2015-03-29 04:20 -0700
Re: TCP sockets python timeout public IP adresss mm0fmf <none@mailinator.com> - 2015-03-29 21:01 +0100
Re: TCP sockets python timeout public IP adresss Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-03-29 18:51 -0400
Re: TCP sockets python timeout public IP adresss bobbdeep <anudeepsm@gmail.com> - 2015-03-30 01:42 -0700
Re: TCP sockets python timeout public IP adresss lucasfneves14 <lucasfneves14@gmail.com> - 2015-10-16 04:44 -0500
Re: TCP sockets python timeout public IP adresss Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-10-16 22:32 +0100
Re: TCP sockets python timeout public IP adresss Grant Edwards <invalid@invalid.invalid> - 2015-10-16 21:45 +0000
Re: TCP sockets python timeout public IP adresss Random832 <random832@fastmail.com> - 2015-10-16 18:57 -0400
Re: TCP sockets python timeout public IP adresss sohcahtoa82@gmail.com - 2015-10-16 17:49 -0700
csiph-web