[Ironpython-users] socketFile.readline never returns

Claudio C claudio at webshell.it
Fri Mar 29 07:01:01 CET 2013


__socketFile is created by this method

def connect(hostName) :
    import errno
    global __connSocket
    global __socketFile
    __connSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    __connSocket.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 0)
    try:
        ret = __connSocket.connect_ex((hostName, __connPort))
    except:
        ret = 101 # ENETUNREACH, Network is unreachable
    if ret == 0:
        __socketFile = __connSocket.makefile("r+", __socketBufSize)
    return ret

On Fri, Mar 29, 2013 at 3:05 AM, Curt Hagenlocher <curt at hagenlocher.org>wrote:

> How was __socketFile created? Is there a possibility that it's looking for
> "\r\n" but only getting "\n"? (I can't remember anything about IronPython's
> handling of eol.)
>
> On Thu, Mar 28, 2013 at 3:53 PM, Claudio C <claudio at webshell.it> wrote:
>
>> Hello everybody,
>>
>> I'm calling this method with IronPython but this never ends cause the
>> second call to readline in the while loop never returns.
>>
>> This doesn't happend with Python 2.7.1 (r271:86832, Jul 31 2011,
>> 19:30:53)
>> [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
>> darwin
>>
>> def __getServerReply() :
>>     """ Internal routine. """
>>     global __socketFile
>>     lines = []
>>     reply = __socketFile.readline(2048)
>>     idx = reply.find(' ')
>>     if idx < 0:
>>         iReply = simwbConstants.NET_BADREPLYFORMAT
>>     else:
>>         iReply = int(reply[:idx])
>>     if iReply == simwbConstants.NET_REPLY_EMPTY:
>>         return (iReply,[])
>>     if iReply == simwbConstants.NET_REPLY_ASCII:
>>         llen = 1
>>         while llen > 0 :
>>             l  = __socketFile.readline(__socketBufSize).rstrip(' \n')
>>             llen = len(l)
>>             if llen > 0:
>>                 lines.append(l)
>>                 print 'added....'
>>
>>         return (iReply,lines)
>>
>>     return (iReply,[])
>>
>> Does anyone know how to fix it?
>>  Many thanks
>>
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> http://mail.python.org/mailman/listinfo/ironpython-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20130329/f6675b96/attachment.html>


More information about the Ironpython-users mailing list