From: <ast...@gm...> - 2007-03-26 17:47:08
|
I'm running "Jython 2.2b1 on java1.5.0_10 (JIT: null)" on WindowsXP. I only have the JRE btw, and it's supposed to be Java 6 (I was playing with jnlp demos on java.sun website tutorials). This is my demo.py (I would have attached it as a file, but I'm not sure if it's allowed in this mailing list): # Begin import java.awt as awt from javax.swing import * import re, socket def regmatch(string, pattern): global regmatched regmatched = [] m = re.search(pattern, string) if m is None: return None regmatched = m.groups() return regmatched class _ActionListener(awt.event.ActionListener): def __init__(self, args): self.args = args def actionPerformed(self, event): self.args() class Demo(JFrame): editbox = JTextField() display = JLabel() def __init__(self, strTitle): self.setTitle(strTitle) self.getContentPane().add(self.display, awt.BorderLayout.CENTER) self.getContentPane().add(self.editbox, awt.BorderLayout.SOUTH) self.setSize(400, 400) self.setLocationRelativeTo(None) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.editbox.addActionListener(_ActionListener(self.parseInput)) def parseInput(self): src = self.editbox txt = src.getText() src.setText('') self.display.setText(txt) if regmatch(txt, '^connect (\S+) (\S+)$'): (host, port) = regmatched self._connect(host, port) def _connect(self, host=None, port=6667): try: print "Host", host print "Port", port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) except socket.error: s.close() if __name__ == "__main__": f = Demo("Test") f.show() #End To reproduce error message below, type "connect irc.dal.net 6667" in the editbox. Exception in thread "AWT-EventQueue-0" Traceback (innermost last): File "demo.py", line 17, in actionPerformed File "demo.py", line 39, in parseInput File "demo.py", line 46, in _connect File "C:\jython2.2b1\Lib\socket.py", line 179, in connect TypeError: java.net.InetSocketAddress(): 1st arg can't be coerced to String or java.net.InetAddress Yes, I'm attempting to write an IRC client. In the actual script that I'm currently writing, the JFrame client and the session are actually two different classes, but I get the same error above anyway. I hope someone can point out my error in this one. If it's a bug, please take note, devs. |