Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.88k stars 531 forks source link

please add sctp protocol support to IO::Socket::INET [rt.cpan.org #68902] #17446

Open toddr opened 6 years ago

toddr commented 6 years ago

Migrated from rt.cpan.org#68902 (status was 'open')

Requestors:

From pro@cpan.org on 2011-06-17 19:12:49:

currently not working:
IO::Socket::INET->new('Proto'    => 'sctp');

very small and simple fix:

```diff
--- INET.pm_    2011-06-17 20:55:56.000000000 +0400
+++ INET.pm     2011-06-17 20:56:35.000000000 +0400
@@ -22,11 +22,13 @@
 IO::Socket::INET->register_domain( AF_INET );

 my %socket_type = ( tcp  => SOCK_STREAM,
+                    sctp => SOCK_STREAM,
                    udp  => SOCK_DGRAM,
                    icmp => SOCK_RAW
                  );
 my %proto_number;
 $proto_number{tcp}  = Socket::IPPROTO_TCP()  if defined 
&Socket::IPPROTO_TCP;
+$proto_number{sctp}  = Socket::IPPROTO_SCTP()  if defined 
&Socket::IPPROTO_SCTP;
 $proto_number{udp}  = Socket::IPPROTO_UDP()  if defined 
&Socket::IPPROTO_UDP;
 $proto_number{icmp} = Socket::IPPROTO_ICMP() if defined 
&Socket::IPPROTO_ICMP;
 my %proto_name = reverse %proto_number;

From leont@cpan.org on 2012-02-21 19:50:18:

I'm not sure this is the most sensible of behaviors. sctp can be used as both a SOCK_STREAM and a SOCK_SEQPACKET: but the former doesn't really make sense (what'd be the advantage over tcp?).

Leon

toddr commented 6 years ago

Given no response to the comment made by @leont in 2012, I'm going to close this. Please re-open if you still would like to discuss this further.

Leont commented 6 years ago

I do think this ticket is valid, but realistically it needs Socket to have more SCTP support

toddr commented 6 years ago

How would you like to action this then? Do we want a perl RT about this?

Leont commented 4 years ago

IMO we should improve our sctp support, the question is should it be SOCK_STREAM or SOCK_SEQPACKET by default. @leonerd got an opinion?

leonerd commented 4 years ago

I don't really know enough about SCTP or the uses of it to suggest either way

FGasper commented 4 years ago

@Leont Perhaps rather than just sctp, there could be both sctp_one (SOCK_STREAM) and sctp_many (SOCK_SEQPACKET)?

Both interface styles are of legitimate interest.

Leont commented 4 years ago

Perhaps rather than just sctp, there could be both sctp_one (SOCK_STREAM) and sctp_many (SOCK_SEQPACKET)?

I think that would only be more confusing. Also, this is only about the default (you can still override the Type argument to set the other), so ultimately it's not all that important.

FGasper commented 4 years ago

I think that would only be more confusing.

In order to use SCTP usefully, though, you have to know whether you want TCP-style/one-to-one or UDP-style/one-to-many, right? It seems to me that any confusion that results from having sctp_one and sctp_many has more to do with not understanding that SCTP does both one-to-one (à la TCP) and one-to-many (à la UDP) interactions.

Leont commented 4 years ago

SOCK_SEQPACKET doesn't mean one-to-many. It means sequential packets (much like a stream, but with actual packet boundaries; or like connected UDP but reliable and ordered).

While SCTP does support multihoming, I don't think that would fit into the interface of IO::Socket::INET/IO::Socket::IP. That will probably require an IO::Socket::SCTP module that probably should at least start out its life outside of this distribution.

FGasper commented 4 years ago

@Leont

SOCK_SEQPACKET doesn't mean one-to-many.

Hrm? Where are you reading that? sctp(7) says:

       A one-to-many style interface with 1 to MANY relationship between  socket
       and  associations  where  the outbound association setup is implicit. The
       syntax of a one-to-many style socket() call is

       sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
Leont commented 4 years ago

Yeah I didn't have that manpage until I just installed it.

I still don't think it'd be helpful to deviate from the socket API too much here (in other words, have 2 arguments instead of 1)

FGasper commented 4 years ago

How would 2 args conform better to the socket API?

tonycoz commented 4 years ago

It seems to me that the current behaviour is reasonable, I don't think we can reasonable select one socket type over the other, so it's reasonable to expect the caller to supply that themselves.

The error returned could be improved though:

$ ./perl -Ilib -MIO::Socket::INET -e '$x = IO::Socket::INET->new(Proto => 'sctp') or die;'
IO::Socket::INET: Socket type not supported     ...propagated at -e line 1.

and that could be improved, maybe:

No default socket type for 'sctp', supply a Type parameter.

would be an improvement.

Leont commented 4 years ago

It seems to me that the current behaviour is reasonable, I don't think we can reasonable select one socket type over the other, so it's reasonable to expect the caller to supply that themselves.

Actually, that is probably the most reasonable suggestion :-)