File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -579,6 +579,23 @@ fn socket_gethostbyaddr(
579
579
) )
580
580
}
581
581
582
+ #[ cfg( not( target_os = "redox" ) ) ]
583
+ fn socket_gethostbyname ( name : PyStringRef , vm : & VirtualMachine ) -> PyResult < String > {
584
+ match socket_gethostbyaddr ( name, vm) {
585
+ Ok ( ( _, _, hosts) ) => {
586
+ let lst = vm. extract_elements :: < PyStringRef > ( & hosts) ?;
587
+ Ok ( lst. get ( 0 ) . unwrap ( ) . to_string ( ) )
588
+ }
589
+ Err ( _) => {
590
+ let error_type = vm. class ( "_socket" , "gaierror" ) ;
591
+ Err ( vm. new_exception_msg (
592
+ error_type,
593
+ "nodename nor servname provided, or not known" . to_owned ( ) ,
594
+ ) )
595
+ }
596
+ }
597
+ }
598
+
582
599
fn get_addr < T , I > ( vm : & VirtualMachine , addr : T ) -> PyResult < socket2:: SockAddr >
583
600
where
584
601
T : ToSocketAddrs < Iter = I > ,
@@ -707,6 +724,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
707
724
extend_module ! ( vm, module, {
708
725
"getaddrinfo" => ctx. new_function( socket_getaddrinfo) ,
709
726
"gethostbyaddr" => ctx. new_function( socket_gethostbyaddr) ,
727
+ "gethostbyname" => ctx. new_function( socket_gethostbyname) ,
710
728
} ) ;
711
729
712
730
extend_module_platform_specific ( vm, & module) ;
You can’t perform that action at this time.
0 commit comments