[IronPython] (no subject)

Curt Hagenlocher curt at hagenlocher.org
Wed Sep 15 09:27:14 CEST 2004

> 	result = "foxpdll"
> 	res = GetBytes(result.ToCharArray())

By the way, this is extraneous, because GetBytes has a string
overload.  You could just say
	res = GetBytes(result)

> 	s.Send(res,res.Length,0)

The reason you're getting "bad args" is that this gets translated
into a method call Socket.Send(byte[], int32, int32), which doesn't
exist.  The closest signature, and the one you probably intended,
is Socket.Send(byte[], int32, SocketFlags) -- SocketFlags is an
enumeration, which is not an int32.  This line would have worked
	s.Send(res, res.Length, SocketFlags.None)
as would the line
	s.Send(res, SocketFlags.None)
and the line
since you're not really changing the meaning of the call by using
the additional parameters.

You could argue that, having not found a matching signature,
FePy should have translated the int32 into a "SocketFlags".  I
would disagree, and assert that the increased readability caused
by forcing use of the specific enumerated type outweighs any
advantages of being able to use a raw int32.

It occurs to me that you may have been thinking of the Stream.Write
function, which has the signature Write(byte[] buffer, int32 length,
int32 position).  The Socket.Send function does not work with the
same parameters.

Curt Hagenlocher
curt at hagenlocher.org

More information about the Ironpython-users mailing list