Mserver HTTP server port range?

Monkey Targets Forums/HTML5/Mserver HTTP server port range?

Redbeer(Posted 2014) [#1]
Could Mark or someone else tell me what the potential range of port numbers are for mserver?
The server itself has a fixed port, but the HTTP listener seems to use a range somewhere in the 623XXX range. It stays consistent once the server is open, but each time it reopens it uses a new port number after localhost as in the URL below, 62339 will change to something else.

http://localhost:62339/MonkeyGame.html

The issue I'm having is that I use the HTML trans to teach Monkey, and one of the tools I have at my teaching disposal is to block the use of certain programs and/or internet for students so they don't get distracted. This is an extremely important thing, because quite a few students will spend whole weeks of class periods with me having to tell them ever five minutes to focus on the task I've given them, if they have access to the internet and other programs. In a class of 25 to 30, this is needless to say very time consuming even if it's only 5 or so students. It would be a lot easier to just block everything for those students EXCEPT Ted, mserver, and the specific site address their code will be translated to, as in the line above.

The problem is, each students localhost number is different every time the mserver is reloaded, for every different student, so I need to create a batch that includes ALL the possible port numbers to filter the URLs.

I guess ideally an mserver application recompiled with on specific fixed port for everyone would be better, but at least if I know all the possible port numbers, I can make my web and application filtering work.

Help is greatly appreciated.


Paul - Taiphoz(Posted 2014) [#2]
some one corrent me if I am wrong but the source code to mserve is in your monkey download, peek through the source, and edit where needed to alter or check the range that it uses.

it would be nice to force it to use the same port all the time, or be able to set a range.


Redbeer(Posted 2014) [#3]
Thanks Paul.
I looked at the source before posting, but there are two issues.
1) It's BlitzMax, which I'm am not so familiar with. I can probably figure it out, but it wasn't obvious what to change, and it seems to use external dependencies that are not included with the source.
2) I don't have BlitzMax to recompile it, even if I can fix it.

For reference, I think this is the code, but I'm unsure exactly how it works given my unfamiliarity with BlitzMax

Local client:TSocket=ConnectToMServer()
	
	Local stream:TSocketStream=CreateSocketStream( client,False )
	
	WriteLine stream,"NEW "+HTTPEncode( ExtractDir(p) )
	
	Local resp$=ReadLine( stream )
	
	CloseSocket client
	
	If resp.StartsWith( "OK " )
		Local port=Int(resp[3..])
?Linux
		system_ "xdg-open ~qhttp://localhost:"+port+"/"+StripDir(p)+"~q"
?Not Linux
		OpenURL "http://localhost:"+port+"/"+StripDir(p)
?		



Redbeer(Posted 2014) [#4]
On further review, it seems that the port does not start from 623 all the time. The same project, in the same directory, that I was testing with before is now using 54XXX. Also, judging by the code it sets the port dynamically from ports somehow mapped to the computer I'm running the server on?

I could, maybe, just set port in the OpenURL to a fixed value, but, as I said, I have no way to compile BlitzMax on my current PC or the Mac's I use at work.


nikoniko(Posted 2014) [#5]
-