can anyone help me with this?
well, I'm trying to write a program in python where it connects to a specified ip address and port no, and then you can send messages at your intended target.
here's the code:
#!/usr/bin/python import socket as sock import threading
print "subliminal messages" print "written by fuser"
IP = raw_input('IP: ') PORT = raw_input('PORT: ')
class submclient(threading.Thread): def init(self, host, port): threading.Thread.init(self) self.host = host self.port = port self.sock = sock.socket(sock.AF_INET, sock.SOCK_STREAM)
def run(self): try: self.sock.connect((self.host, self.port)) print "%s:%d OPEN" % (self.host, self.port) self.sd.close() except: pass
send = raw_input('Send: ') sock.send(send) print sock.recv(2048) sock.close()
class submserver(threading.Thread): def init(self, port): threading.Thread_init_(self) def run(self): self.host = '' self.addr = (self.host, self.port) self.buf = 1024 def run(self): sock.bind((self.host, self.port)) sock.listen(1)
and here's the error when I compile it:
Traceback (most recent call last): File "subm.py", line 26, in <module> sock.send(send) AttributeError: 'module' object has no attribute 'send'
so does any one knows how to fix this?
I can only suggest that your use of import socket as sock is messing things up. Try import socket (or from socket import *), its probably safe to do in this app, just never do it with the os module (im sure you know this :p)
–Edit– After looking at richo's python chat script (basically the same thing) I think you can figure out whats wrong by seeing how he did it. I tihnk its here: http://www.freewebs.com/richohealey/python/chat.py
jjbutler88 wrote:
–Edit– After looking at richo's python chat script (basically the same thing) I think you can figure out whats wrong by seeing how he did it. I tihnk its here: http://www.freewebs.com/richohealey/python/chat.py
yeah i've seen it, no use besting the master huh?
I guess I've to re-review the code