Hi, I'm trying to implement a simple server. What I want the code to do
is as follows: * Create a socket and listen on a port * Wait for an incoming connection * When a connection is received, fork a process to deal with it and go back to waiting for connections. I believe the following code should accomplish this (I have omitted the loop and the fork because I want to get it working for a single connection before I start with multiple connections!): server := Socket new. server listenOn: 1234. client := server accept. However when I run this I get Socket(Object)>>primitiveFailed. Examining the stack trace reveals the source to be this method: Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex: <primitive: 'primitiveSocketAccept' module: 'SocketPlugin'> ^self primitiveFailed When I take a look in /usr/local/lib/squeak/3.11.3-2135 there are lots of plugins, but no SocketPlugin. Swazoo seems to work fine without it and all of the tests in the NetworkTests package pass. _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Hi, what image version are you running?
cheers, Mike On Wed, Apr 14, 2010 at 1:33 AM, Daniel Birkinshaw <[hidden email]> wrote: > Hi, I'm trying to implement a simple server. What I want the code to do > is as follows: > > * Create a socket and listen on a port > * Wait for an incoming connection > * When a connection is received, fork a process to deal with it and go > back to waiting for connections. > > I believe the following code should accomplish this (I have omitted the > loop and the fork because I want to get it working for a single > connection before I start with multiple connections!): > > server := Socket new. > server listenOn: 1234. > client := server accept. > > However when I run this I get Socket(Object)>>primitiveFailed. Examining the stack trace reveals the source to be this method: > > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex: > <primitive: 'primitiveSocketAccept' module: 'SocketPlugin'> > ^self primitiveFailed > > When I take a look in /usr/local/lib/squeak/3.11.3-2135 there are lots of plugins, but no SocketPlugin. Swazoo seems to work fine without it and all of the tests in the NetworkTests package pass. > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users > _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
which VM are you using ? how are you launching the vm ? which OS ?
what are the results of do you have such plugin in SmalltalkImage current listLoadedModules ? cheers mariano On Wed, Apr 14, 2010 at 11:42 PM, Michael Roberts <[hidden email]> wrote: Hi, what image version are you running? _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Michael Roberts-2
I'm running Pharo-1.0-10515-rc3dev10.03.1
On Wed, Apr 14, 2010 at 10:42:08PM +0100, Michael Roberts wrote: > Hi, what image version are you running? > > cheers, > Mike > > On Wed, Apr 14, 2010 at 1:33 AM, Daniel Birkinshaw > <[hidden email]> wrote: > > Hi, I'm trying to implement a simple server. What I want the code to do > > is as follows: > > > > * Create a socket and listen on a port > > * Wait for an incoming connection > > * When a connection is received, fork a process to deal with it and go > > back to waiting for connections. > > > > I believe the following code should accomplish this (I have omitted the > > loop and the fork because I want to get it working for a single > > connection before I start with multiple connections!): > > > > server := Socket new. > > server listenOn: 1234. > > client := server accept. > > > > However when I run this I get Socket(Object)>>primitiveFailed. Examining the stack trace reveals the source to be this method: > > > > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex: > > <primitive: 'primitiveSocketAccept' module: 'SocketPlugin'> > > ^self primitiveFailed > > > > When I take a look in /usr/local/lib/squeak/3.11.3-2135 there are lots of plugins, but no SocketPlugin. Swazoo seems to work fine without it and all of the tests in the NetworkTests package pass. > > > > _______________________________________________ > > Pharo-users mailing list > > [hidden email] > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users > > > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Mariano Martinez Peck
On Wed, Apr 14, 2010 at 11:46:41PM +0200, Mariano Martinez Peck wrote:
> which VM are you using ? squeak 3.11.3-2135 > how are you launching the vm ? By typing 'squeak' in a terminal. I have squeak.image, squeak.changes and PharoV10.sources symlinked to the appropriate files in my pharo installation directory. > which OS ? Ubuntu Linux (I'd switch to something better but I just don't have the time right now). > do you have such plugin in > SmalltalkImage current listLoadedModules > or > SmalltalkImage current listBuiltinModules Yes, it's in builtinModules: 'SocketPlugin 26 August 2009 (i)' _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
On Thu, Apr 15, 2010 at 12:34 AM, Daniel Birkinshaw <[hidden email]> wrote:
Can you try with 4.0.3.2202 Unix VM from: http://squeakvm.org/unix/ And: http://gforge.inria.fr/frs/download.php/24736/pharo-vm-0.15.2f-linux.zip Do you still have the same problem ?
ok...
Ok...it is ok to be in buildInModules I think....but, if it was used, it should also appear in listLoadedModules weird...did you evaluate that even after running network tests? cheers mariano
_______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
On Thu, Apr 15, 2010 at 01:27:54AM +0200, Mariano Martinez Peck wrote:
> Can you try with *4.0.3.2202 Unix VM *from: http://squeakvm.org/unix/ > And: > http://gforge.inria.fr/frs/download.php/24736/pharo-vm-0.15.2f-linux.zip Same result with both of those, although I did notice that SocketPlugin appears in listLoadedModules in pharo-vm (but not in squeak-4.0.3). I also tried the official squeak-4.0 image (I'd forgotten how annoying that is to use; there's just stuff *everywhere*) but same result. It's looking like the problem is with the configuration of my machine. I'm going to reboot now and try the Windows version. > weird...did you evaluate that even after running network tests? I know right? Everything seems to be working until I try to use it! Surely I must just be doing something wrong. _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
On Thu, Apr 15, 2010 at 01:37:22AM +0100, Daniel Birkinshaw wrote:
> I also tried the official squeak-4.0 image (I'd forgotten how annoying > that is to use; there's just stuff *everywhere*) but same result. It's > looking like the problem is with the configuration of my machine. I'm > going to reboot now and try the Windows version. Ok I just got back from my Windows installation, same result there too. That would appear to leave only one possibility: the code I've written is invalid. I can't see what's wrong with it though. _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Daniel Birkinshaw
Thanks for reporting...
Daniel can you also try: http://squeakvm.org/unix/release/Squeak-4.0.3.2202-linux_i386.tar.gz binaries http://lolgzs.free.fr/pharo/Pharo-1.0-OneClick.zip Stef On Apr 15, 2010, at 2:37 AM, Daniel Birkinshaw wrote: > On Thu, Apr 15, 2010 at 01:27:54AM +0200, Mariano Martinez Peck wrote: > >> Can you try with *4.0.3.2202 Unix VM *from: http://squeakvm.org/unix/ >> And: >> http://gforge.inria.fr/frs/download.php/24736/pharo-vm-0.15.2f-linux.zip > > Same result with both of those, although I did notice that SocketPlugin > appears in listLoadedModules in pharo-vm (but not in squeak-4.0.3). > > I also tried the official squeak-4.0 image (I'd forgotten how annoying > that is to use; there's just stuff *everywhere*) but same result. It's > looking like the problem is with the configuration of my machine. I'm > going to reboot now and try the Windows version. > >> weird...did you evaluate that even after running network tests? > > I know right? Everything seems to be working until I try to use it! > Surely I must just be doing something wrong. > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
On Thu, Apr 15, 2010 at 09:19:55AM +0200, Stéphane Ducasse wrote:
> Thanks for reporting... > Daniel can you also try: > > http://squeakvm.org/unix/release/Squeak-4.0.3.2202-linux_i386.tar.gz binaries > http://lolgzs.free.fr/pharo/Pharo-1.0-OneClick.zip > > Stef No luck there either I'm afraid. Also I should mention that the launcher script that comes with squeak 4.0.3 and is used by the pharo oneclick package segfaults on my machine. I don't know the exact cause, but modifying the script to remove the call to padsp allows it to run correctly. I'll attach the output if you want, but I suspect it might be more appropriate to report it to the upstream devs. _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Hi, i think there is something wrong with listenOn:. I am not sure
what exactly. the variation below seems to work in Pharo 1.0 on OS X. | server client | server := Socket new. server listenOn: 12345 backlogSize: 4. server waitForConnectionFor: 600. client := server accept. client receiveData --> 'hello ' and from a shell echo hello | nc localhost 12345 I also check the status of my sockets using lsof which is quite good to debug mike-mac:~ mike$ lsof -n -i -P | grep Squeak Squeak 10787 mike 11u IPv4 0x66bc270 0t0 TCP *:54180 (LISTEN) Squeak 10787 mike 12u IPv4 0x66c1a68 0t0 TCP 127.0.0.1:12345->127.0.0.1:54183 (CLOSE_WAIT) You can also have a look at ConnectionQueue which implements a server loop like you describe hope that helps cheers, Mike On Thu, Apr 15, 2010 at 1:08 PM, Daniel Birkinshaw <[hidden email]> wrote: > On Thu, Apr 15, 2010 at 09:19:55AM +0200, Stéphane Ducasse wrote: >> Thanks for reporting... >> Daniel can you also try: >> >> http://squeakvm.org/unix/release/Squeak-4.0.3.2202-linux_i386.tar.gz binaries >> http://lolgzs.free.fr/pharo/Pharo-1.0-OneClick.zip >> >> Stef > > No luck there either I'm afraid. > > Also I should mention that the launcher script that comes with squeak > 4.0.3 and is used by the pharo oneclick package segfaults on my machine. > I don't know the exact cause, but modifying the script to remove the > call to padsp allows it to run correctly. I'll attach the output if you > want, but I suspect it might be more appropriate to report it to the > upstream devs. > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users > _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
On Sat, Apr 17, 2010 at 06:32:22PM +0100, Michael Roberts wrote:
> Hi, i think there is something wrong with listenOn:. I am not sure > what exactly. the variation below seems to work in Pharo 1.0 on OS X. > > | server client | > server := Socket new. > server listenOn: 12345 backlogSize: 4. > server waitForConnectionFor: 600. > client := server accept. > client receiveData > --> 'hello ' > > > and from a shell > echo hello | nc localhost 12345 Confirmed, that works for me. I infer from this that it is illegal to call accept with a backlogSize of 0. Perhaps this should be checked for at a higher level so that a meaningful error can be returned? I was surprised to note that accept returns immediately even if there is no client connected. Try removing the line "server waitForConnectionFor: 600." in your example. The code still runs but the socket it returns is in the connected state even though it can't possibly be connected to anything. Is this behaviour correct? I thought accept was a blocking call. I'll look into ConnectionQueue, thanks for the help. _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Daniel
if we could we would rewrite all the network code :) Stef On Apr 18, 2010, at 1:19 AM, Daniel Birkinshaw wrote: > On Sat, Apr 17, 2010 at 06:32:22PM +0100, Michael Roberts wrote: >> Hi, i think there is something wrong with listenOn:. I am not sure >> what exactly. the variation below seems to work in Pharo 1.0 on OS X. >> >> | server client | >> server := Socket new. >> server listenOn: 12345 backlogSize: 4. >> server waitForConnectionFor: 600. >> client := server accept. >> client receiveData >> --> 'hello ' >> >> >> and from a shell >> echo hello | nc localhost 12345 > > Confirmed, that works for me. I infer from this that it is illegal to > call accept with a backlogSize of 0. Perhaps this should be checked for > at a higher level so that a meaningful error can be returned? > > I was surprised to note that accept returns immediately even if there is > no client connected. Try removing the line "server waitForConnectionFor: > 600." in your example. The code still runs but the socket it returns is > in the connected state even though it can't possibly be connected to > anything. Is this behaviour correct? I thought accept was a blocking > call. > > I'll look into ConnectionQueue, thanks for the help. > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Daniel Birkinshaw
On Sun, Apr 18, 2010 at 1:19 AM, Daniel Birkinshaw <[hidden email]> wrote:
+1 If you want to can commit a little change for that, I think would be ok. Create an issue in the bugtracker add a unit test if possible! I was surprised to note that accept returns immediately even if there is _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Free forum by Nabble | Edit this page |