Do sockets work in the Linux VM? When trying methods like openTCPHost I get an error about the slot socketConstants not existing.
I notice this is defined in 'traits unixFile osVariants bsd' so I copied this slot into the linux variants. Unfortunately any attempt to call openTCPHost from then fails with ECONNREFUSED. Attempting to track this down in the debugger is proving difficult due to other issues I'm having with fonts. Has anyone been able to use the socket routines?
Chris.
On Tue, Jul 21, 2009 at 10:44 PM, Chris Doublechris@double.co.nz wrote:
I notice this is defined in 'traits unixFile osVariants bsd' so I copied this slot into the linux variants.
This is how you can test the problem from the shell. On Linux, to copy across the socketConstants:
os_file parent osVariants linux _AddSlots: (| socketConstants = traits unixFile osVariants bsd socketConstants |).
This is how I then called openTCPHost:
"Self 21" os_file openTCPHost: "Self 21" os_file openTCPHost: 'double.co.nz' Port: '80' Error: connect failed: ECONNREFUSED. Receiver is: raiseError.
Chris.
I found the issue. The problem is in vm/src/unix/prims/unixPrims.cpp. The address in set_sockaddr_in isn't copied under Linux. The fix is:
# if TARGET_OS_VERSION == SOLARIS_VERSION \ - || TARGET_OS_VERSION == MACOSX_VERSION + || TARGET_OS_VERSION == MACOSX_VERSION \ + || TARGET_OS_VERSION == LINUX_VERSION memcpy((char*) &aLong, address, sizeof(long)); memset(a.sin_zero, 0, sizeof(a.sin_zero));
I've put a git repository up with the following fixes:
1) The fix for the above issue 2) Added socketConstants for Linux 3) Fix to get the build working under Linux - uses flex, and modifies an include header line for <new>.
Note that for (2) I manually edited objects/core/unix.self. I'm not sure if this is the right way to do it. I originally did the change under the UI but didn't know how to file it out such that it will be recreated when bootstrapping a new image.
The changes are in my fork of the github self repository in the master branch: git://github.com/doublec/self.git
To test it you can file in the web browser code:
bootstrap read: 'webBrowser' From: 'applications/webBrowser'
Then in a shell:
'http://www.w3.org/' asURL getPageForUser
Unfortunately it shows an error page since this browser doesn't support HTTP 1.1. Just about every webserver around uses virtual hosts and it doesn't send a Host: header. But the error page is the HTML served from the W3C website so it shows the browser and socket code working.
Chris.
You are the perfect open source user - you find a bug, work out the issue and provide a patch all within a single day! :)
If you can send me an email at mail@russell-allen.com saying that
(a) you irrevocably licence your changes under the Self licence at
http://github.com/russellallen/self/raw/48fdb6b84d9680d9d50598d082efed834dd8...
(ie SELF_WORKING_DIR/legal/LICENSE) and
(b) you are happy for me to add the changes to the github repo.
then I'll pull your changes across to the main repository and add you to the AUTHORS file.
------------------------
If you don't want to edit .self files directly, you need to use the transporter. A good place to start is
http://selflanguage.org/_static/manuals/Self-4.1-Pgm-Env.pdf
I should do a screencast at some stage though, as it's better to see it in action then read about it.
- Russell
On 21/07/2009, at 11:51 PM, Chris Double wrote:
I found the issue. The problem is in vm/src/unix/prims/unixPrims.cpp. The address in set_sockaddr_in isn't copied under Linux. The fix is:
# if TARGET_OS_VERSION == SOLARIS_VERSION \
- || TARGET_OS_VERSION == MACOSX_VERSION
- || TARGET_OS_VERSION == MACOSX_VERSION \
- || TARGET_OS_VERSION == LINUX_VERSION
memcpy((char*) &aLong, address, sizeof(long)); memset(a.sin_zero, 0, sizeof(a.sin_zero));
I've put a git repository up with the following fixes:
- The fix for the above issue
- Added socketConstants for Linux
- Fix to get the build working under Linux - uses flex, and modifies
an include header line for <new>.
Note that for (2) I manually edited objects/core/unix.self. I'm not sure if this is the right way to do it. I originally did the change under the UI but didn't know how to file it out such that it will be recreated when bootstrapping a new image.
The changes are in my fork of the github self repository in the master branch: git://github.com/doublec/self.git
To test it you can file in the web browser code:
bootstrap read: 'webBrowser' From: 'applications/webBrowser'
Then in a shell:
'http://www.w3.org/' asURL getPageForUser
Unfortunately it shows an error page since this browser doesn't support HTTP 1.1. Just about every webserver around uses virtual hosts and it doesn't send a Host: header. But the error page is the HTML served from the W3C website so it shows the browser and socket code working.
Chris.
On Wed, Jul 22, 2009 at 1:07 PM, Russell Allenmail@russell-allen.com wrote:
If you can send me an email at mail@russell-allen.com saying that ,,,
Thanks, done.
If you don't want to edit .self files directly, you need to use the transporter.
Aha, this is definitely a better approach. I used the 'changed modules' option from middle clicking on the background and just pressed 'w' on the change I wanted and it updated the file for me.
As a test of using that I made a change to webBrowser to send the 'Host:' header. This allows it to be used on sites that use virtual hosts. The commit is here:
http://github.com/doublec/self/commit/3ca257c32ff02747da8fe9e48a52b4a7d8c04a61
An example that works with this change: 'http://www.double.co.nz' asURL getPageForUser
Chris.
self-interest@lists.selflanguage.org