[Pharo-project] Networking problems on Pharo 1.2.1

Oscar E A Callau oalvarez at dcc.uchile.cl
Thu Apr 21 07:17:30 CEST 2011


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>




More information about the Pharo-project mailing list