[Pharo-project] Networking problems on Pharo 1.2.1
Hi all, may be this is a simple/stupid/repetitive question, but I don't know how to solve it. I'm trying to connect two sockets on Pharo 1.2.1, with following code: Server -------- |port msg| port:= 9191. Transcript open; show: 'testing --- ' ; cr. listening := true. [self isListening] whileTrue: [ |server connectedClient| server := Socket newTCP. server listenOn: port. connectedClient := server waitForAcceptFor: 5. connectedClient ifNil: [msg:='TimeOut'] ifNotNil:[ msg := 'Data: ', connectedClient receiveData connectedClient closeAndDestroy ]. Transcript show: msg ; cr. server closeAndDestroy. ]. Transcript show: 'end ------'. ------------ Client ------------ | s | s:= Socket newTCP. s connectToHostNamed: 'localhost' port: 9191. s sendData: 'Hello'. s closeAndDestroy --------- First I run the server and later the client and get the following error: Error: primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex: failed I attach a screenshot of the debug window. Thanks in advance.
Hi again, I found a solution (but not what was the problem); change the server code to the following: |port msg| port:= 9191. Transcript open; show: 'testing --- ' ; cr. listening := true. [self isListening] whileTrue: [ |server connectedClient| server := Socket newTCP. server listenOn: port. connectedClient := [server waitForConnectionFor: 5] on: ConnectionTimedOut do: [] . server isConnected ifTrue: [ msg:= 'Data: ', server receiveData. Transcript show: msg ; cr. ]. server closeAndDestroy. ]. Transcript show: 'end ------'. basically, I'm changing #waitForAcceptFor: for #waitForConnectionFor: I hope someone can explain me what are the differences. Cheers On Apr 20, 2011, at 23:20 , Oscar E A Callau wrote:
Hi all, may be this is a simple/stupid/repetitive question, but I don't know how to solve it.
I'm trying to connect two sockets on Pharo 1.2.1, with following code:
Server --------
|port msg| port:= 9191.
Transcript open; show: 'testing --- ' ; cr.
listening := true. [self isListening] whileTrue: [ |server connectedClient| server := Socket newTCP. server listenOn: port. connectedClient := server waitForAcceptFor: 5. connectedClient ifNil: [msg:='TimeOut'] ifNotNil:[ msg := 'Data: ', connectedClient receiveData connectedClient closeAndDestroy ]. Transcript show: msg ; cr. server closeAndDestroy. ].
Transcript show: 'end ------'.
------------ Client ------------
| s | s:= Socket newTCP. s connectToHostNamed: 'localhost' port: 9191. s sendData: 'Hello'. s closeAndDestroy
---------
First I run the server and later the client and get the following error:
Error: primAcceptFrom:receiveBufferSize:sendBufSize:semaIndex: failed
I attach a screenshot of the debug window.
Thanks in advance.
<Screen shot 2011-04-20 at 23.16.48 .png>
On 04/21/2011 07:17 AM, Oscar E A Callau wrote:
Hi again,
I found a solution (but not what was the problem); change the server code to the following:
Just a tip: Please use SocketStream, it will help you when doing the actual sending/receiving. In almost every situation SocketStream is your friend. regards, Göran
Hi, Yes SocketStream is useful but still, the socket base layer should be usable without problems ... I do not know why #waitForAcceptFor: do not make it. #Luc 2011/4/21 Göran Krampe <goran@krampe.se>
On 04/21/2011 07:17 AM, Oscar E A Callau wrote:
Hi again,
I found a solution (but not what was the problem); change the server code to the following:
Just a tip: Please use SocketStream, it will help you when doing the actual sending/receiving. In almost every situation SocketStream is your friend.
regards, Göran
+1 I would love to know the answer. On Apr 21, 2011, at 9:26 AM, Luc Fabresse wrote:
Hi,
Yes SocketStream is useful but still, the socket base layer should be usable without problems ... I do not know why #waitForAcceptFor: do not make it.
#Luc
2011/4/21 Göran Krampe <goran@krampe.se> On 04/21/2011 07:17 AM, Oscar E A Callau wrote: Hi again,
I found a solution (but not what was the problem); change the server code to the following:
Just a tip: Please use SocketStream, it will help you when doing the actual sending/receiving. In almost every situation SocketStream is your friend.
regards, Göran
participants (5)
-
Göran Krampe -
Luc Fabresse -
Oscar E A Callau -
Stéphane Ducasse -
Sven Van Caekenberghe