Message3112

Author asterio
Recipients asterio
Date 2008-04-01.08:17:49
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1207037870.44.0.230320661588.issue1018@psf.upfronthosting.co.za>
In-reply-to
Content
When a UDP socket try to read from a remote socket, the data is 
received right, but the remote address, ports always are set to (None, -
1)

I give a two simple codes that reflects this issue.
-------------------------------
#UDP Server
import socket
import select

fd=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
rnetLoc = ('0.0.0.0', 12000)
fd.bind( rnetLoc )

while True:
    print "waiting....at", rnetLoc
        
    fd.setblocking(0)   # jython 
    s,_,e = select.select( [fd] , [], [fd], 10)
    
    for r in s:
        print "Activity from", r.getsockname()
        
        fd.setblocking(1)   # jython 
        raw, rnetLoc = r.recvfrom(4096)
        fd.setblocking(0)   # jython 
        #rnetLoc = '%s:%s' % rnetLoc
        print "%s from %s" % (str(raw), str(rnetLoc)) # jython always 
give (None, -1) instead something like ('127.0.0.1', 12001)
        # in Python works fine.
    
--------------------------
#UDP Client
import socket
import select
import time

fd=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
rnetLoc = ('0.0.0.0', 12001)
fd.bind( rnetLoc )

rnetLoc = ('127.0.0.1', 12000)
while True:
    
    print "sending....at", rnetLoc
        
    fd.setblocking(0)   # jython 
    _,s,e = select.select( [] , [fd], [fd], 10)
    
    for w in s:
        print "Can write using", w.getsockname()
        
        fd.setblocking(1)   # jython 
        print rnetLoc
        l = fd.sendto('Hola', rnetLoc)
        fd.setblocking(0)   # jython 
        time.sleep(2)
-----------------------------------------
I hope this helps
History
Date User Action Args
2008-09-12 00:31:29nrileysetspambayes_score: 0.354985 -> 0.0
2008-04-01 08:17:50asteriosetspambayes_score: 0.354985 -> 0.354985
recipients: + asterio
2008-04-01 08:17:50asteriosetspambayes_score: 0.354985 -> 0.354985
messageid: <1207037870.44.0.230320661588.issue1018@psf.upfronthosting.co.za>
2008-04-01 08:17:50asteriolinkissue1018 messages
2008-04-01 08:17:49asteriocreate