July 26th, 2005, 06:24 PM
What are the reason that socket.connect() fails?
Hello this sounds to be quite general question rather than to be specific. However i just want to know something about this friendly earlier and mysterious at present socket.connect() function..
I am using socket.connect() function in my code in several classess. However I found that in most of them it is working fine. Today i wrote one class in which i am trying to make socket connection to my bridge.
I am using:
well self.server is initialised with 192.168.100.254 and self.port as 2067
self.socket = socket.socket(socket.AF_INET,socket_SOCK_STREAM)
print "error: failed to open socket"
My problem is that it is not working. I am using similar nature of socket in different class and here too i am connecting and everything seems to be fine.
I just wann know that what can be the reason for the socket .conect to fail?
July 26th, 2005, 06:47 PM
Your code is completely incorrect. First of all, you only use "self" when dealing with class objects. You must create a global (preferrably) variable that equals socket.socket(socket.AF_INET,socket_SOCK_STREAM). For instance:
Then to connect:
s = socket.socket(socket.AF_INET,socket_SOCK_STREAM)
'asia.battle.net' would be replaced by the server you want to connect to, and '6112' would be replaced by the servers port.
July 27th, 2005, 01:04 PM
thanks for reply.
Well I am using the all socket stuff in function of my class. I do apologise for my earlier incomplete / confusing post. self.socket = None has been initialised in my class __init__ function. and hence i am using it in my function say connect(self): as self.socket.
I hope now it does makes sense.
July 27th, 2005, 04:06 PM
Re-read my post, and make s equal self.s. Then to connect you would do:
July 28th, 2005, 12:15 AM
Ok this is a really dumb question, but lets say I made a socket connection, what can I do with it? I mean the usage.
What can change the nature of a man?
July 28th, 2005, 03:23 PM
Send/receive data from other computers.
July 30th, 2005, 03:13 PM
and more high level stuff if you use different modules like htmllib or httplib or something like ftplib and smtplib(email) and ...
Those people who think they know everything are a great annoyance to those of us who do.
July 30th, 2005, 07:46 PM
Which is sending/receiving data.
Originally Posted by monkeyman23555