5.0

5.0 | 5 ratings Rate this file 43 Downloads (last 30 days) File Size: 103.63 KB File ID: #29027
image thumbnail

Web Server

by Dirk-Jan Kroon

 

14 Oct 2010 (Updated 18 Oct 2011)

HTTP Matlab Web Server, allows m-files to be executed in a browser

| Watch this File

File Information
Description

This function WEBSERVER, is a HTTP webserver for HTML code and images and also allows execution of Matlab code through the web.

   webserver(port)

 Supports
   - HTML and images
   - Sub-Folders
   - Upload files
   - M file execution

 Example,
  webserver(4000);
  % Use firefox or internet explorer and visit http://localhost:4000/
 

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
18 Oct 2010 Nicolas Billard

It's interesting project apart some stability problems.

The following message is often displayed (when i launch webserver first time, it's ok. If i stop it and run it again, it's rain of messages) :

??? Java exception occurred:
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
Error in ==> JavaTcpServer at 10
        serverSocket = ServerSocket(data);
Error in ==> webserver at 33
TCP=JavaTcpServer('initialize',[],port);

Other problem, i must refresh sometimes until almost 10 times before the server executes my url.

If you have any suggestion to improve the stability, I'm very interested.

27 Oct 2010 Dirk-Jan Kroon

*Nicolas Billard

Thank you for your comments.

The Java-error is due to earlier usage of the port without correctly closing/disconnecting the port due to a code-crash or other problem. In the future I will probably try to solve that by storing the port in a Matlab global, making it possible to close the port after a code crash.

I didn't experience the refresh problems my self. But the code is very experimental, and still more like a prove of concept. Hopefully i will find time to improve the code in the near future, or maybe somebody else will create his own project from this with more stable code.

25 Nov 2010 Dirk-Jan Kroon

*Nicolas Billard
Today I uploaded the version which solves your problems (will probably be online tomorrow) ...

16 Dec 2010 Nicolas Billard

I can confirm it works well.

04 Feb 2011 Aleksandar Pavic

Very interesting, I will test this, I've made php-console bridge on linux...

24 Mar 2011 Adam Leadbetter

Very nice piece of code. It works very well for me.

30 Aug 2011 Sung  
28 Sep 2011 Ernest

Hi.. how do I automatically reset the webserver whenever I encounter this error:

Java exception occurred:
java.net.SocketException: Software caused connection abort: socket write error

That is, I dont need to go to matlab and re-run webserver(80) manula in the command window.

Thank you.

18 Oct 2011 Mathias Bustamante

Excelent piece of code, very useful !
Thanks

09 Feb 2012 Changshun Deng

Does this need appach or IIS?

Please login to add a comment or rating.
Updates
25 Nov 2010

Fixed Java-Port error due to code crash, and fixed refresh bug by waiting longer for the data. Problems where reported by "Nicolas Billard"

25 Nov 2010

Now it also works with the "ICE-browser" in Matlab. Also added error information and config options.

29 Nov 2010

Update for ice-browser

18 Oct 2011

Solved:
- Chinese character-set bug (reported by Ernest)
- Try and catch around java connection error caused by IE
- added config variable to function-header

Tag Activity for this File
Tag Applied By Date/Time
http Dirk-Jan Kroon 14 Oct 2010 12:15:52
server Dirk-Jan Kroon 14 Oct 2010 12:15:52
matlab Dirk-Jan Kroon 14 Oct 2010 12:15:52
webserver Dirk-Jan Kroon 14 Oct 2010 12:15:52
web server Dirk-Jan Kroon 14 Oct 2010 12:15:52
web Dirk-Jan Kroon 14 Oct 2010 12:15:53
firefox Dirk-Jan Kroon 14 Oct 2010 12:15:53
internet explorer Dirk-Jan Kroon 14 Oct 2010 12:15:54
html Dirk-Jan Kroon 14 Oct 2010 12:15:54
php Dirk-Jan Kroon 14 Oct 2010 12:15:54
upload Dirk-Jan Kroon 14 Oct 2010 12:15:54
apache Dirk-Jan Kroon 14 Oct 2010 12:15:54
tcp Dirk-Jan Kroon 14 Oct 2010 12:15:54
tcpip Dirk-Jan Kroon 14 Oct 2010 12:15:54
webserver Adam Leadbetter 24 Mar 2011 11:00:07
web server Adam Leadbetter 24 Mar 2011 11:00:12
http Adam Leadbetter 24 Mar 2011 11:00:16
php mathieu 19 Jul 2011 04:35:45
firefox mathieu 19 Jul 2011 04:37:11
apache Tigran 13 Jan 2012 15:52:38
server GGG 14 Feb 2012 11:36:56
tcp GGG 14 Feb 2012 11:37:05
apache Elias 18 Apr 2012 04:53:58

Contact us at files@mathworks.com