[IronPython] (no subject)

J. Merrill jvm_cop at spamcop.net
Fri Sep 10 07:33:56 PDT 2004


When mentioning an exception, you should always give the description of the exception, and where it occurs in your code.  If the exception was from the Connect call, that's completely different than if the exception was from the Receive call.

Did it take a while for the exception to appear?  You specified that you wanted to receive 1024 bytes into the buffer.  If there aren't that many bytes available, it might be that an exception is raised.  Examples in the .NET documentation suggest that you might better ask for s.Available bytes (that's the number of bytes currently available to be received on the socket).

It should not be necessary to specify the buffer length; both Python and .NET know that the buffer is 1024 bytes.  The ability to read a specified number of bytes is, I believe, provided so that if the protocol being used tells you the length of the following data, you can read exactly the amount you want.

Why are there extra indentation levels on the "hostEndPoint =" and "print s.Receive" lines?

At 06:37 AM 9/10/2004, =?windows-1251?B?z/Du9vv46O0gxOzo8vDo6Q==?= wrote
>Hello users-ironpython.com,
>
>
>had this
>why exeptions rised?
>what type of RecvBytes neded for normal work?
>
>from System import *
>from System.Text import *
>from System.IO import *
>from System.Net import *
>from System.Net.Sockets import *
>
>RecvBytes="*"1024
>print RecvBytes.Length
>
>s = Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
>hostInfo = Dns.Resolve("mail.ru")
>for curAdd in hostInfo.AddressList:
>        print curAdd.ToString()
>        hostEndPoint = IPEndPoint(curAdd, 110)
>        s.Connect(hostEndPoint)
>            print s.Receive(RecvBytes, RecvBytes.Length, 0)
>
>
>Best regards, 
>  
>Ïðîöûøèí Äìèòðèé (ñèñòåìíûé àäìèíèñòðàòîð)
>ÇÀÎ "Êîìèíêîì ÷åðíîçåìüå"
>512-125
>8-905-65-66-927
>icq 49606850
>Ïðîöûøèí Äìèòðèé
>foxpdll at comch.ru
>2004-09-10_______________________________________________
>users-ironpython.com mailing list
>users-ironpython.com at lists.ironpython.com
>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


J. Merrill / Analytical Software Corp



More information about the users-ironpython.com mailing list