Hello, i have been trying to use some async sockets , and after some tryes and
google reading i have found that there is no select module on jython. So, i
just jumped to the next solution, that is, using java native Selectors...
but for some reason my code doesn't works. It's almost the same example from
Java translated to jypthon.
It opens a socket, accepts a connection... but cant read from the channel!!
this is the code... some ideas?
from java.io import *
from java.net import *
from java.nio import *
from java.nio.channels import *
from java.nio.charset import *
selector = Selector.open()
# // Create two non-blocking server sockets on 80 and 81
ssChannel1 = ServerSocketChannel.open()
# // Register both channels with selector
# // Wait for an event
# // Get list of selection keys with pending events
it = selector.selectedKeys().iterator()
# // Process each key
# // Get the selection key
selKey = it.next()
# # // Remove it from the list to indicate that it is being processed
# // Check if it's a connection request
# // Get channel with connection request
ssChannel = selKey.channel()
buf = ""
i = ssChannel.read(buf)
if i != -1:
# // See e178 Accepting a Connection on a ServerSocketChannel
# // for an example of accepting a connection request