sigar/go_bindings/gotoc/netconnections.go

51 lines
715 B
Go
Raw Permalink Normal View History

2016-01-04 18:23:11 +08:00
package gotoc
import (
"unsafe"
)
/*
#include "../../../../../Include/sigar.h"
*/
import "C"
func NetConections(flags int)(C.sigar_net_connection_list_t,
[]C.sigar_net_connection_t){
var sigar *C.sigar_t=GetSigarHandle()
var netlistconn C.sigar_net_connection_list_t
C.sigar_net_connection_list_get(sigar, &netlistconn, C.int(flags))
var length int=int(netlistconn.number)
cconnection:=GetGoSlice(length, unsafe.Pointer(netlistconn.data))
var goConnections []C.sigar_net_connection_t
goConnections = *(*[]C.sigar_net_connection_t)(unsafe.Pointer(&cconnection))
C.sigar_net_connection_list_destroy(sigar, &netlistconn)
return netlistconn, goConnections
}