Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88251 > unrolled thread

TCP sockets python timeout public IP adresss

Started bybobbydeep <anudeepsm@gmail.com>
First post2015-03-29 01:57 -0700
Last post2015-10-16 17:49 -0700
Articles 12 — 9 participants

Back to article view | Back to comp.lang.python


Contents

  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

#88251 — TCP sockets python timeout public IP adresss

Frombobbydeep <anudeepsm@gmail.com>
Date2015-03-29 01:57 -0700
SubjectTCP sockets python timeout public IP adresss
Message-ID<fcccc2e0-b554-424a-a24f-df6b86f8b3cb@googlegroups.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

[toc] | [next] | [standalone]


#88253

Frombobbdeep <anudeepsm@gmail.com>
Date2015-03-29 03:03 -0700
Message-ID<b42210c5-e2d2-458d-a7da-fea61837b27a@googlegroups.com>
In reply to#88251
Changed server code to the following,

from socket import *

HOST = ''
PORT = 8080
serversocket = socket(AF_INET,SOCK_STREAM)
serversocket.bind((HOST,PORT))
serversocket.listen(5)
while True:
    (clientsocket, address) = serversocket.accept()
    print ("Got client request from",address)
    clientsocket.send("Thank You for connecting")
    clientsocket.close()



Still getting same error.

[toc] | [prev] | [next] | [standalone]


#88254

Frommm0fmf <none@mailinator.com>
Date2015-03-29 11:14 +0100
Message-ID<agQRw.1295066$Wk7.1286582@fx28.am4>
In reply to#88251
On 29/03/2015 09:57, bobbydeep wrote:

 From the error (10060) it looks like Windows but it would be nice if 
you could say which Python and OS you were using.

I haven't looked at your code but just taking at face value that it does 
work internally.

> server_address = ('my-server-ipadress', 1999)

Next thing to check is whether you have permission to open arbitrary 
ports on the server and whether they are firewalled off. For example, I 
have a shell account on the server that hosts my webpages and I can run 
ftp / scp to move files across the internet. However, I cannot open say 
port 54321 to the internet and accept connections on it.

[toc] | [prev] | [next] | [standalone]


#88259

Frombobbdeep <anudeepsm@gmail.com>
Date2015-03-29 04:20 -0700
Message-ID<98896311-5b4c-4242-a7ec-080cbe2462dd@googlegroups.com>
In reply to#88254
On Sunday, March 29, 2015 at 3:44:43 PM UTC+5:30, mm0fmf wrote:
> On 29/03/2015 09:57, bobbydeep wrote:
> 
>  From the error (10060) it looks like Windows but it would be nice if 
> you could say which Python and OS you were using.
> 
> I haven't looked at your code but just taking at face value that it does 
> work internally.
> 
> > server_address = ('my-server-ipadress', 1999)
> 
> Next thing to check is whether you have permission to open arbitrary 
> ports on the server and whether they are firewalled off. For example, I 
> have a shell account on the server that hosts my webpages and I can run 
> ftp / scp to move files across the internet. However, I cannot open say 
> port 54321 to the internet and accept connections on it.

I am using windows 8 and python 2.7.7. I did an nmap to my server to identify the list of open ports on my server. I found out that only three ports are open. How do I add a port to the list of open ports on my server ?
server version:
Linux hostname 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

[toc] | [prev] | [next] | [standalone]


#88280

Frommm0fmf <none@mailinator.com>
Date2015-03-29 21:01 +0100
Message-ID<pSYRw.1512045$I4.702597@fx34.am4>
In reply to#88259
On 29/03/2015 12:20, bobbdeep wrote:
> How do I add a port to the list of open ports on my server ?

Ask the system administrator.

[toc] | [prev] | [next] | [standalone]


#88293

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-03-29 18:51 -0400
Message-ID<mailman.319.1427669500.10327.python-list@python.org>
In reply to#88259
On Sun, 29 Mar 2015 04:20:09 -0700 (PDT), bobbdeep <anudeepsm@gmail.com>
declaimed the following:

>
>I am using windows 8 and python 2.7.7. I did an nmap to my server to identify the list of open ports on my server. I found out that only three ports are open. How do I add a port to the list of open ports on my server ?
>server version:
>Linux hostname 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

	That's an OS/Firewall question -- nothing to do with Python itself.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#88324

Frombobbdeep <anudeepsm@gmail.com>
Date2015-03-30 01:42 -0700
Message-ID<71606603-0f84-4677-96c0-71c88982a56f@googlegroups.com>
In reply to#88251
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.

[toc] | [prev] | [next] | [standalone]


#97752

Fromlucasfneves14 <lucasfneves14@gmail.com>
Date2015-10-16 04:44 -0500
Message-ID<OMGdnY9IwNCYWr3LnZ2dnUU7-TmdnZ2d@giganews.com>
In reply to#88251
How did you do it?

[toc] | [prev] | [next] | [standalone]


#97760

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-10-16 22:32 +0100
Message-ID<mailman.61.1445031308.4562.python-list@python.org>
In reply to#97752
On 16/10/2015 10:44, lucasfneves14 wrote:
> How did you do it?
>

I conned my way in, nobody suspected it.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#97761

FromGrant Edwards <invalid@invalid.invalid>
Date2015-10-16 21:45 +0000
Message-ID<mvrr5c$qv4$1@reader1.panix.com>
In reply to#97752
On 2015-10-16, lucasfneves14 <lucasfneves14@gmail.com> wrote:

> How did you do it?

I just climbed in and pushed the button.  Same as always.

-- 
Grant Edwards               grant.b.edwards        Yow! This MUST be a good
                                  at               party -- My RIB CAGE is
                              gmail.com            being painfully pressed up
                                                   against someone's MARTINI!!

[toc] | [prev] | [next] | [standalone]


#97762

FromRandom832 <random832@fastmail.com>
Date2015-10-16 18:57 -0400
Message-ID<mailman.62.1445036305.4562.python-list@python.org>
In reply to#97752
lucasfneves14 <lucasfneves14@gmail.com> writes:

> How did you do it?

That's an impressive reply gap. 

If anyone's wondering, this is apparently in reply to this from March:
http://thread.gmane.org/gmane.comp.python.general/774441

[toc] | [prev] | [next] | [standalone]


#97765

Fromsohcahtoa82@gmail.com
Date2015-10-16 17:49 -0700
Message-ID<88d83374-7325-4ffe-a3cc-f97941b48415@googlegroups.com>
In reply to#97752
On Friday, October 16, 2015 at 2:44:53 AM UTC-7, lucasfneves14 wrote:
> How did you do it?

I took the advice of just being myself.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web