[IronPython] Two problems
Joao Grilo
grilo at netcabo.pt
Fri Aug 13 00:46:09 CEST 2004
Consider the following code:
---------------------------------------------------------------
import System
import System.Net
import System.Net.Sockets
def callbackFunction(socket):
socket.Close()
## IronPython quirk: must cast "arrays" to lists, for them to work properly
hostAddress = list(System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList)[0]
hostEndpoint = System.Net.IPEndPoint(hostAddress, 1800)
socket = System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
System.Net.Sockets.SocketType.Stream,
System.Net.Sockets.ProtocolType.Tcp)
socket.Bind(hostEndpoint)
socket.Listen(1)
print """Runs up to this point"""
asyncAccept = socket.BeginAccept(System.AsyncCallback(callbackFunction), socket)
print """This won't show at all, due to a core dump"""
while asyncAccept.IsCompleted == False:
print '.'
-----------------------------------------------------------
There are 2 (two) problems to be noted:
The Array held by "System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList"
can't be accessed normaly, and *must* be cast to a list() object prior to use it.
1. Shouldn't "Array" objects be automatically converted to lists?
I can't get the callbackFunction function to be called at all. It simply core dumps
as soon as that line is executed, and it returns this:
%ironpython helloworldIronPython.py
Runs up to this point
** ERROR **: file object.c: line 1595 (mono_runtime_invoke_array): assertion failed: (((gpointer*)params->vector) [i])
aborting...
Abort trap (core dumped)
If I run the C# (C Sharp) Server example code found in
http://www.go-mono.com/docs/monodoc.ashx?link=T%3aSystem.Net.Sockets.Socket it works
perfectly, but not mine.
2. Does my code contain a bug, or is IronPython not doing the right thing?
Thank you for your attention.
Sincerely yours
João Grilo
More information about the Ironpython-users
mailing list