[Tutor] Socket Programming
Alan Gauld
alan.gauld at btinternet.com
Mon Apr 8 11:02:04 CEST 2013
On 08/04/13 08:06, Mousumi Basu wrote:
> import socket
> import sys
> s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
> try:
> s=s.bind(('172.18.2.11',2213))
> print 'socket bind is complete'
> except socket.error,msg:
> print 'bind failed'
> sys.exit()
Your first error is that when developing you don't want to hide the
error messages so add a raise statement to the except block so you get
the full traceback with all of its helpful details.
> but when i am writting;-
>
> s=s.bind(('localhost',2213))
>
> the output is;-
> socket bind is complete
Which suggests that the 172... IP address you are using above is not
recognised... or maybe has a firewall around it, or some other
restrictions on access.
> Can you please tell me where i am making the error?
> (The computers are connected as the ping operation is executing properly
> in command prompt)
It is most likely a network configuration issue but only you can fix
that since we can't see how the network is set up. Rather than using
ping try using telnet to reach the IP address and port and see what
response you get.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list