Example #1
0
File: pbs.go Project: jbarber/pbs
// Pbs_connect makes a connection to server, or if server is an empty string, the default server. The returned handle is used by subsequent calls to the functions in this package to identify the server.
func Pbs_connect(server string) (int, error) {
	str := C.CString(server)
	defer C.free(unsafe.Pointer(str))

	handle := C.pbs_connect(str)
	if handle < 0 {
		return 0, errors.New(Pbs_strerror(int(C.pbs_errno)))
	}

	return int(handle), nil
}
Example #2
0
// ConnectServer open connection to serverName.
func ConnectServer(serverName string) (*Torque, error) {
	srv := C.CString(serverName)
	con := int(C.pbs_connect(srv))
	C.free(unsafe.Pointer(srv))

	if con < 0 {
		return nil, GetLastError()
	}

	return &Torque{serverName: serverName, serverID: con}, nil
}