How to debug primitive failures?

Chris Pettitt cpettitt at vidigiani.dyndns.org
Wed May 21 18:50:20 UTC 2003


Hi Andreas,

Excellent! Thank you very much for the details :). I will use the backlog
call from now.

Thanks,
Chris

On Wed, 21 May 2003, Andreas Raab wrote:

> Hi Chris,
>
> You're running into a legacy trap. Years back, when the socket primitives
> were invented the meaning of #listenOn: was to 'accept a single connection
> inplace'.
>
> Here's an example:
>
> | server client |
> server := Socket newTCP.
> server listenOn: 12345.
> client := Socket newTCP.
> client connectTo: NetNameResolver localHostAddress port: 12345.
> client waitForConnectionUntil: (Socket deadlineSecs: 1).
>
> Once the client has established the connection, the server is already bound
> so trying to 'accept' anything from it is not going to work (that's the
> primitive failure you see). The message you want to use is
> #listenOn:backlogSize: e.g.,
>
> | listener client accepted |
> listener := Socket newTCP.
> listener listenOn: 12345 backlogSize: 4.
> client := Socket newTCP.
> client connectTo: NetNameResolver localHostAddress port: 12345.
> client waitForConnectionUntil: (Socket deadlineSecs: 1).
> accepted := listener waitForAcceptUntil: (Socket deadlineSecs: 1).
>
> Cheers,
>   - Andreas
>
>
> > -----Original Message-----
> > From: squeak-dev-bounces at lists.squeakfoundation.org
> > [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On
> > Behalf Of Chris Pettitt
> > Sent: Wednesday, May 21, 2003 7:52 PM
> > To: The general-purpose Squeak developers list
> > Subject: How to debug primitive failures?
> >
> >
> > Somehow lost the subject when I sent this out. I should also note that
> > this primitive failure is raised after I connect to the server socket
> > using telnet.
> >
> > Thanks,
> > Chris
> >
> > On Wed, 21 May 2003, Chris Pettitt wrote:
> >
> > > When I try to run the following code, I get a "primitive has failed"
> > > error:
> > >
> > > Socket initializeNetwork.
> > > acceptor _ Socket newTCP.
> > > acceptor listenOn: 8000.
> > > [
> > >  connection _ acceptor waitForAcceptUntil: (Socket
> > deadlineSecs: 120).
> > >  connection ~= nil ifTrue: [
> > >   [Transcript show: 'Received Connection!'. connection close.] fork.
> > >  ].
> > >  false.
> > > ] whileTrue.
> > > acceptor close.
> > >
> > > My question is: how do I debug a primitive error in Squeak?
> > I would have a
> > > lot better luck debugging this if I could find the C code,
> > I am sure.
> > >
> > > Thanks,
> > > Chris
> > >
> > >
> > >
> > > Here is the stack, for those interested:
> > >
> > > VM: Win32 - Squeak3.4 of 1 March 2003 [latest update: #5170]
> > > Image: Squeak3.5 [latest update: #5180]
> > >
> > > Socket(Object)>>error:
> > >  Receiver: a Socket[destroyed]
> > >  Arguments and temporary variables:
> > >   aString:  'a primitive has failed'
> > >  Receiver's instance variables:
> > >   semaphore:  a Semaphore()
> > >   socketHandle:  nil
> > >   readSemaphore:  a Semaphore()
> > >   writeSemaphore:  a Semaphore()
> > >   primitiveOnlySupportsOneSemaphore:  true
> > >
> > > Socket(Object)>>primitiveFailed
> > >  Receiver: a Socket[destroyed]
> > >  Arguments and temporary variables:
> > >
> > >  Receiver's instance variables:
> > >   semaphore:  a Semaphore()
> > >   socketHandle:  nil
> > >   readSemaphore:  a Semaphore()
> > >   writeSemaphore:  a Semaphore()
> > >   primitiveOnlySupportsOneSemaphore:  true
> > >
> > > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex:
> > >  Receiver: a Socket[destroyed]
> > >  Arguments and temporary variables:
> > >   aHandle:  a ByteArray(16 94 73 70 0 0 0 0 248 96 11 0)
> > >   rcvBufSize:  8000
> > >   sndBufSize:  8000
> > >   semaIndex:  15
> > >  Receiver's instance variables:
> > >   semaphore:  a Semaphore()
> > >   socketHandle:  nil
> > >   readSemaphore:  a Semaphore()
> > >   writeSemaphore:  a Semaphore()
> > >   primitiveOnlySupportsOneSemaphore:  true
> > >
> > >
> > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex
> > :readSemaIndex:writeSemaIndex:
> > >  Receiver: a Socket[destroyed]
> > >  Arguments and temporary variables:
> > >   aHandle:  a ByteArray(16 94 73 70 0 0 0 0 248 96 11 0)
> > >   rcvBufSize:  8000
> > >   sndBufSize:  8000
> > >   semaIndex:  15
> > >   aReadSema:  16
> > >   aWriteSema:  17
> > >  Receiver's instance variables:
> > >   semaphore:  a Semaphore()
> > >   socketHandle:  nil
> > >   readSemaphore:  a Semaphore()
> > >   writeSemaphore:  a Semaphore()
> > >   primitiveOnlySupportsOneSemaphore:  true
> > >
> > >
> > > --- The full stack ---
> > > Socket(Object)>>error:
> > > Socket(Object)>>primitiveFailed
> > > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex:
> > >
> > Socket>>primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex
> > :readSemaIndex:writeSemaIndex:
> > >  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> > > Socket>>acceptFrom:
> > > [] in Socket class>>acceptFrom:
> > > BlockContext>>repeatWithGCIf:
> > > Socket class>>acceptFrom:
> > > Socket>>accept
> > > Socket>>waitForAcceptUntil:
> > >
> >
>
>



More information about the Squeak-dev mailing list