'From Croquet1.0beta of 24 March 2006 [latest update: #6665] on 26 March 2006 at 9:42:05 pm'!
"Change Set:		SocketPluginDPR
Date:			26 March 2006
Author:			Andreas Raab

David's extensions folded into SocketPlugin."!


!Socket methodsFor: 'accessing' stamp: 'ar 3/26/2006 21:40'!
beReusable
	"Make this socket reusable"
	self primSocketSetReusable: socketHandle.! !

!Socket methodsFor: 'connection open/close' stamp: 'ar 3/26/2006 21:39'!
bindTo: addr port: aPort
	self primSocket: socketHandle bindTo: addr port: aPort! !

!Socket methodsFor: 'primitives' stamp: 'ar 3/26/2006 21:40'!
primSocketSetReusable: aHandle 
	<primitive: 'primitiveSocketSetReusable' module: 'SocketPlugin'>
	^self primitiveFailed! !

!Socket methodsFor: 'primitives' stamp: 'ar 3/26/2006 21:40'!
primSocket: aHandle bindTo: addr port: aPort
	<primitive: 'primitiveSocketBindToPort' module: 'SocketPlugin'>
	^self primitiveFailed! !


!SocketPlugin methodsFor: 'primitives' stamp: 'ar 3/26/2006 21:31'!
primitiveSocketSetReusable: socket
	"Set the socket to be reusable"
	| s |
	self var: #s declareC: 'SocketPtr s'.
	self primitive: 'primitiveSocketSetReusable'
		parameters: #(Oop).
	s _ self socketValueOf: socket.
	interpreterProxy failed ifFalse: [
		self sqSocketSetReusable: s]! !

!SocketPlugin methodsFor: 'primitives' stamp: 'ar 3/26/2006 21:32'!
primitiveSocket: socket bindTo: address port: port 
	| addr s  |
	self var: #s declareC: 'SocketPtr s'.
	self primitive: 'primitiveSocketBindToPort' parameters: #(#Oop #ByteArray #SmallInteger ).
	addr _ self
				netAddressToInt: (self cCoerce: address to: 'unsigned char *').
	s _ self socketValueOf: socket.
	interpreterProxy failed 
		ifFalse:[self sqSocket: s BindTo: addr Port: port]! !

