DDE syntax help
Hello, I am trying to convert an Excel SpreadSheet to Python. The formula in Excel for one of the cells is =DDE("ser1","ser2","ser3"). The name of the server is ser1, ser2 is the topic, and ser3 is an item. I already tried using: >>> import dde >>> ddes = dde.CreateServer() >>> ddes.Create("ser1") >>> ddec = dde.CreateConversation(ddes) >>> ddec.ConnectTo("ser1","ser3") >>> ddec.Connected() 1 All is ok so far. However: >>> ddec.Request("ser2") Traceback (most recent call last): File "", line 1, in ? error: Request failed >>> ddec.Exec("ser2") Traceback (most recent call last): File "", line 1, in ? error: Exec failed >>> Does anyone know the syntax to request information from a DDE server? I could not find any useful examples in the documentation. Thank you, Dana __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
getting data from a port in use
Hi to all, I am trying to use Python to get the data received at a specific port (in use) on my computer. I already tried below code which seems to hang at the statement accepting connections. I don't know what else I can try. Any suggestions will be welcome. import socket, select, os PORT = 2005 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((socket.gethostname(), PORT)) s.listen(1) work_socket, addr = s.accept() data = s.recv(1024) print data s.close() Thank you, Dana __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
RE: getting data from a port in use
--- Tony Meyer <[EMAIL PROTECTED]> wrote: > > I am trying to use Python to get the data received at a > > specific port (in use) on my computer. I already tried below > > code which seems to hang at the statement accepting > > connections. > > Seems to hang, or does hang? Using print statements will tell you > whether > that's where it's getting stuck or not. > > > I don't know what else I can try. Any > > suggestions will be welcome. > > > > import socket, select, os > > > > PORT = 2005 > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > s.bind((socket.gethostname(), PORT)) > > s.listen(1) > > work_socket, addr = s.accept() > > data = s.recv(1024) > [...] > > This should be 'data = work_socket.recv(1024)'. > > This script works for me with that change. (i.e. I can run it with port > 2005 already in use, connect to the port, and it will finish without > error). > > =Tony.Meyer > > __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
RE: getting data from a port in use
Yes. It hangs at accept. I always end up doing end task because it never passes the "accept" statement. When I set the port I use netstat (netstat -bn) to get the ports that are in use. I use PythonWin 2.4. I am still puzzled about the fact that it runs fine for you. You are right about using the work_socket instead of s. My program never ran to that line so I did not notice the error. Thank you, Dana --- Tony Meyer <[EMAIL PROTECTED]> wrote: > > I am trying to use Python to get the data received at a > > specific port (in use) on my computer. I already tried below > > code which seems to hang at the statement accepting > > connections. > > Seems to hang, or does hang? Using print statements will tell you > whether > that's where it's getting stuck or not. > > > I don't know what else I can try. Any > > suggestions will be welcome. > > > > import socket, select, os > > > > PORT = 2005 > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > s.bind((socket.gethostname(), PORT)) > > s.listen(1) > > work_socket, addr = s.accept() > > data = s.recv(1024) > [...] > > This should be 'data = work_socket.recv(1024)'. > > This script works for me with that change. (i.e. I can run it with port > 2005 already in use, connect to the port, and it will finish without > error). > > =Tony.Meyer > > __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo -- http://mail.python.org/mailman/listinfo/python-list
getting data from a port in use
Yes. I want to write a very small web sniffer that gets data from a specified port. I already looked at some of the existing ones on Internet, but they are not in Python (I am trying to learn Python!) and they have a lot more features that I want. Thanks for your suggestion. I will check out pcap library. Dana On 2005-02-01, Dana Marcusanu <[EMAIL PROTECTED]> wrote: > I am trying to use Python to get the data received at a specific port (in > use) on my computer. What do you mean "in use"? You mean you want to evesdropt on data that's being sent to an existing connection? If so, you'll need to use something like the pcap library. > I already tried below code which seems to hang at the > statement accepting connections. I don't know what else I can try. Any > suggestions will be welcome. > import socket, select, os > PORT = 2005 > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > s.bind((socket.gethostname(), PORT)) > s.listen(1) > work_socket, addr = s.accept() > data = s.recv(1024) No matter what you're trying to do, this isn't right. Once the connection has been accepted, you have to read data from the socket returned by the accept() call. > print data > s.close() -- Grant Edwards grante Yow! Actually, what at I'd like is a little toy visi.comspaceship!! __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list