pharo-vm icon indicating copy to clipboard operation
pharo-vm copied to clipboard

Feat/improvements in sockets

Open tesonep opened this issue 2 years ago • 4 comments

tesonep avatar May 16 '23 13:05 tesonep

I can't fully follow most of this, but thought I'd point something out. I noticed in digging around to deal with pharo#11723 that there already exist separate primSocket:bindTo:port: and primSocket:listenWithBacklog: which together comprise the functionality of primSocket:listenOn:backlogSize:interface:. So it's entirely possible to remove the whole primSocket:listenOn:backlogSize:interface: family of primitives altogether, and then implement:

Socket>>listenOn: portNumber backlogSize: backlog interface: ifAddr

	self
		bindTo: ifAddr port: portNumber;
		listenWithBacklog: backlog

The default values for parameters can be provided by the image as well:

listenOn: portNumber backlogSize: backlog
	self listenOn: portNumber backlogSize: backlog interface: SocketAddress zero

listenOn: port
	self listenOn: port backlogSize: 1

I think this is cleaner in a few ways—it keeps more behavior in the image, where it's easy for a user not familiar with the VM to understand and modify. It also hews closer to the call sequence that people with sockets programming experience outside of Smalltalk would recognize. I'd be happy to create the PR for updating the image code if you'd like to incorporate this into your changes.

daniels220 avatar Sep 01 '23 19:09 daniels220

I think this is cleaner in a few ways—it keeps more behavior in the image, where it's easy for a user not familiar with the VM to understand and modify. It also hews closer to the call sequence that people with sockets programming experience outside of Smalltalk would recognize. I'd be happy to create the PR for updating the image code if you'd like to incorporate this into your changes.

Oh yes, please, I'd be happy to!

guillep avatar Sep 04 '23 08:09 guillep

Alright, see pharo#14593. The image changes don't depend on VM changes, but do leave the primSocket:listenOn:backlogSize:interface: family orphaned/unused—you can go ahead and remove them as part of your changes here.

daniels220 avatar Sep 05 '23 19:09 daniels220

Something funny is happenning there:

       0x3402ad4f8 s Process>pvtSignal:list:
       0x3402ad5e8 s Process>pvtSignal:list:
       0x3402ad6d8 s Process>pvtSignal:list:
       0x3402ad7c8 s Process>pvtSignal:list:
       0x3402ad8b8 s Process>pvtSignal:list:
       0x3402ad9a8 s Process>pvtSignal:list:
       0x3402ada98 s Process>pvtSignal:list:
       0x3402adb88 s Process>pvtSignal:list:
       0x3402adc78 s Process>pvtSignal:list:
       0x3402add68 s Process>pvtSignal:list:
       0x3402ade58 s Process>pvtSignal:list:
       0x3402adf48 s Process>pvtSignal:list:
       0x28001fc78 I Process>resume 0x3400ee1d0: a(n) Process
       0x28001fcc0 I FullBlockClosure(BlockClosure)>forkAt:named: 0x3400eeaa8: a(n) FullBlockClosure
       0x28001fd28 I TCPSocketEchoTest>withTCPEchoServer: 0x10005158908: a(n) TCPSocketEchoTest
       0x28001fd80 I [] in TCPSocketEchoTest>testEcho 0x10005158908: a(n) TCPSocketEchoTest

guillep avatar Sep 08 '23 14:09 guillep