]> gitweb.factorcode.org Git - factor.git/commitdiff
io.sockets: adding port-protocol to match protocol-port.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 30 Jul 2016 18:12:40 +0000 (11:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 30 Jul 2016 18:12:40 +0000 (11:12 -0700)
basis/io/sockets/sockets.factor

index 5bc245d989c6b03f99b481d1dd1db02f41909cf9..4cee6fb3a49a97ac51246f8cb21fbeb069a59e23 100644 (file)
@@ -459,6 +459,9 @@ M: invalid-local-address summary
 : protocol-port ( protocol -- port )
     [ f getservbyname [ port>> htons ] [ f ] if* ] [ f ] if* ;
 
+: port-protocol ( port -- protocol )
+    [ htons f getservbyport [ name>> ] [ f ] if* ] [ f ] if* ;
+
 : <any-port-local-inet4> ( -- inet4 ) f 0 <inet4> ;
 : <any-port-local-inet6> ( -- inet6 ) f 0 <inet6> ;