Socket problems : ConnectionTimedOut

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Socket problems : ConnectionTimedOut

douglas mcpherson
Hi all,

I am running latest stable 3.8, and writing an app which must  
communicate using several sockets. I am having recurring, yet not  
consistent, errors  when trying to connect to remote  TCP sockets.  
The error is in Socket >>connectTo:port: waitForConnectionFor:  with  
a ConnectionTimedOut exception. I have been trying to track down what  
is going on, but don't seem to be making much headway. The problem is  
that the timeouts are always set to 45 (seconds), but the so-called  
timeout errors occur immediately after trying to connect, without  
waiting the for timeout period. In Socket>>waitForConnectionFor: ,  
the code which should be performing the waiting is:

Socket >>waitForConnectionFor: timeout ifTimedOut: timeoutBlock
        "Wait up until the given deadline for a connection to be  
established. Return true if it is established by the deadline, false  
if not."

        | status deadline |
        deadline _ Socket deadlineSecs: timeout.
        status _ self primSocketConnectionStatus: socketHandle.
        [(status = WaitingForConnection) and: [Time millisecondClockValue <  
deadline]]
                whileTrue: [
                        semaphore waitTimeoutMSecs: (deadline - Time millisecondClockValue).
                        status _ self primSocketConnectionStatus: socketHandle].

        status = Connected ifFalse: [^timeoutBlock value]

This method is usually invoked following a  
Socket>>primSocket:connectTo:port:. . Since no waiting appears to  
occur, it seems that the socket status is not 'WaitingForConnection'  
as is expected, and the method returns without waiitng, and with no  
connection.

I have been playing with this on both Mac OS X (G4) and Win XP  
platforms, and see the same problems. Anybody else? Suggestions? Thanks.

Regards,
Doug

Reply | Threaded
Open this post in threaded view
|

Re: Socket problems : ConnectionTimedOut

Edgar J. De Cleene
Douglas:

File in the attached.

Use

Socket initializeNetwork.
    socket _ Socket newTCP.
    socket
        connectTo: (NetNameResolver addressForName: serverName)
        port: 8000.
    socket waitForConnectionUntil: Socket standardDeadline

And let me know how works for you , I use on OS x and Windows

Edgar




Socket.st (5K) Download Attachment