It is probably my fault for specifying short, MFC has generated this function prototype:
long CMUSHclientDoc::UdpSend(LPCTSTR IP, short Port, LPCTSTR Text)
However a bit of testing reveals that it appears to correctly handle a number larger than 32767, as internally it calls htons, which has this prototype:
u_short htons (
u_short hostshort
);
It passes down "Port" to that function, so even though technically it is negative it all seems to resolve itself.
Thus you should be able to use a port in the range 0 to 65535.
Ah, ok; so the VB binding to Winsock is what's limiting things? I checked the UDP protocol (e.g. http://en.wikipedia.org/wiki/User_Datagram_Protocol) and it says that the max is 65k, like TCP/IP.
I don't remember how VB handles type coercion between signed/unsigned types. If you were to enter 65k into a 'short' parameter, would that wrap around to the appropriate negative number (and then back to positive by the UDP handler) or does that generate an error?
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
What do you mean by 'Lua'? Lua has no native support for sockets. Is this using the Lua Socket library? It states in the reference (for TCP/IP, at least) that the number can't be greater than 65k.
http://www.cs.princeton.edu/~diego/professional/luasocket/tcp.html#bind
However Lua itself doesn't distinguish between the various integer types (the default native number type is double), so it would let you enter whatever you want.
And is VB using a signed or unsigned short? A signed would go to 32k, but the unsigned short would go up to 65k which is the proper value.
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
I was just messing around with the Immediate window, and UDP Sending, to a "program" I scripted in AutoIt, and noticed an issue in the port numbering. In LUA you can use ANY actual port number, as it will accept a LONG integer, and yet in VP it will only accept a SHORT integer, so only to about 32k and some hundreds more ...
It is not a real problem, except for those that try to send on a port that is VERY unlikely to be used for any COMMERCIAL application.
I don't know if it happens in other languages, but it is quite possible it would.
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.